A web service returns an xml string with french text in it. When printing the xml node
xmlResponse.LoadXml(resp);
XmlNode Text = xmlResponse.SelectSingleNode("/res/Text");
sMessageText = Text.InnerText;
the text looks like this:
eg Le nom de le propri taire de carte doit tre entre 4 et 32 caract res
How do I encode it? How do I show readable text.
Thank you
您可能必须设置要使用字符串的控件的Cultureinfo,我不确定哪个属性,但应将其分配给CultureInfo("fr-FR");
I dont think there is a method out of the box in XmlDocument class to load and convert the encoding. You can try the following, its from the link i gave you, the documentation for System.Text.Encoding :
Encoding ascii = Encoding.ASCII;
Encoding unicode = Encoding.Unicode;
// Convert the string into a byte array.
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.
char[] asciiChars = new char[ascii.GetCharCount(asciiBytes, 0, asciiBytes.Length)];
ascii.GetChars(asciiBytes, 0, asciiBytes.Length, asciiChars, 0);
string asciiString = new string(asciiChars);
You just need to change it for the encodings you're using. Also you might want to check this question , it has many answers that might help you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.