'windows-1255' is not a supported encoding name
I'm writing a silverlight 5 application in which I need to read a text file from the user.
Here is a snippet of my code:
using (StreamReader reader = new StreamReader(fileStream, Encoding.GetEncoding("windows-1255")))
But I get the exception: "'windows-1255' is not a supported encoding name". Why is that?
And then, how do I read a file in the "windows-1255" encoding? (Hebrew)
There are not many supported encodings in Silverlight. Basically, you get UTF8 and UTF16, see http://msdn.microsoft.com/en-us/library/t9a3kf7c%28VS.95%29.aspx
You can read your file as binary then convert yourself to UTF (8 or 32, I don't know Hebrew). You'll need a table of all the characters (256), then you can loop on your input file and translate directly.
i ran into this problem again,
And after lots and lots of Googleing i found this amazing tool!
this little piece of art that was created by "Philipp Sumi (@phsumi)", takes the name or code page of a well known encoding, and creates a custom Encoding class which compiles under Silverlight.
it does so by reading the existing encoding in wpf, and redactor it to work under silverlight.