In Windows, I can use the Encoding.GetEncoding ("Windows-1252") via .NET to retrieve the "Windows-1252" code page encoding. Unfortunately, this call throws an ArgumentExtception in Windows Phone 8 emulator, specifying that the encoding name is not valid. I looked around MSDN but didn't find anything useful. Does anyone know about which encodings are available in Windows Phone 8 and which is the new name of the "Windows-1252" encoding?
And yes, I am aware of the alternative option of using the "iso-8859-1" encoding and manually substituting the characters in the 129-159-range. But I'm trying to avoid that if possible.
Many thanks, Michael
I am not sure this still works but remember it was useful. This tools generates the source code for a single byte code pages
http://www.hardcodet.net/2010/03/silverlight-text-encoding-class-generator
I hope the generated source works in windows phone subset of the base class library.
As the exception message so clearly told you, the framework subset on Windows Phone doesn't come with support for Windows-1252. As you say, using Latin-1 (ISO-8859-1) is a way to do it.
Alternatively you can implement the encoding manually, which I wouldn't recommend.
How about trying MultiByteToWideChar(Win32 API)?
Sample code is here.
http://bluewatersoft.cocolog-nifty.com/blog/2012/12/windows-phone-8.html
This is a samplle for CP-932(Shift JIS). Create a new "Windows Phone Runtime Component"(C++) project, then copy the code. Change the constant "CP_SJIS" for you, please.
In addition, I don't know whether CP-1252(Windows-1252) is effective on WP8.
来源:https://stackoverflow.com/questions/14110730/reading-windows-1252-encoding-in-windows-phone-8