Reputation: 605
In my Silverlight Application I am getting an XML File encoded with windows-1252. Now my Problem it won't display correctly until the windows-1252 string is converted to a UTF8 string. In a normal C# enviornment that wouldn't be that big of a problem: There I could do something like this:
Encoding wind1252 = Encoding.GetEncoding(1252);
Encoding utf8 = Encoding.UTF8;
byte[] wind1252Bytes = ReadFile(Server.MapPath(HtmlFile));
byte[] utf8Bytes = Encoding.Convert(wind1252, utf8, wind1252Bytes);
string utf8String = Encoding.UTF8.GetString(utf8Bytes);
(Convert a string's character encoding from windows-1252 to utf-8)
But silverlight doesn't support windows-1252 - it is unicode only.
PS I stumbled upon "Encoding for Silverlight" http://encoding4silverlight.codeplex.com/ - but it seems there is no support for windows-1252 there either?
EDIT: I solved my problem on the "Server Side" - The actual problem is still open.
Upvotes: 2
Views: 1674
Reputation: 1663
Encoding for Silverlight
is a third party encoding system but only supported all DBCS (Double-Byte Character Set)
now. However, windows-1252 is SBCS (Single-Byte Character Set)
.
But you can write a encoder/decoder for Encoding for Silverlight
, I Think will be very easy.
Upvotes: 1