1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
   |  
// ma string
string asciiString = "INSERT INTO toto VALUES ('tototéàè')";
 
            // Create two different encodings.
            Encoding ascii = Encoding.ASCII;
            Encoding unicode = Encoding.UNICODE;
;
 
            // Convert the string into a byte[].
            byte[] asciiBytes = ascii.GetBytes(asciiString);
 
            // Perform the conversion from one encoding to the other.
            byte[] unicodeBytes = Encoding.Convert(ascii, unicode, asciiBytes);
 
            // Convert the new byte[] into a char[] and then into a string.
            // This is a slightly different approach to converting to illustrate
            // the use of GetCharCount/GetChars.
            char[] unicodeChars = new char[unicode.GetCharCount(unicodeBytes, 0, unicodeBytes.Length)];
            unicode.GetChars(unicodeBytes, 0, unicodeBytes.Length, unicodeChars, 0);
            string unicodeString = new string(unicodeChars);
 
            // Display the strings created before and after the conversion.
            MessageBox.Show(Encoding.GetEncoding(0).ToString());
            MessageBox.Show("Original string: " + asciiString);
// enfin je regarde si la requête passe
            MessageBox.Show("unicode converted string: " + unicodeString);
            MessageBox.Show(Param.ExecuteQuery(unicodeString).ToString()); | 
Partager