Bonjour,

je lit une donnée sur le port série.
La chaine de caractères reçus contient des accents. Or je n'arrive pas à les afficher.
Je tente de modier l'encodage pour pouvoir le mettre en UTF8 mais cela ne marche pas les accents sont toujours remplacés par des '?'.

Text = Pserie.ReadLine();

string unicodeString = Text;

// Create two different encodings.
Encoding ascii = Encoding.UTF8;
Encoding unicode = Encoding.Unicode;

// Convert the string into a byte[].
byte[] unicodeBytes = unicode.GetBytes(unicodeString);

// Perform the conversion from one encoding to the other.
byte[] asciiBytes = Encoding.Convert(unicode, ascii, unicodeBytes);

// 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[] asciiChars = new char[ascii.GetCharCount(asciiBytes, 0, asciiBytes.Length)];
ascii.GetChars(asciiBytes, 0, asciiBytes.Length, asciiChars, 0);
string asciiString = new string(asciiChars);

// Display the strings created before and after the conversion.
MessageBox.Show(unicodeString);
MessageBox.Show(asciiString);

Merci de votre aide