Having trouble geting the encoding right in my silverlight application.
I need support for western europe letters like æ,ø,å,â and so(Latin1??).
But I can’t get it right. What should be instead of SOMEENCODINGHERE? did try
Encoding enc = Encoding.GetEncoding(“Latin1”); but no names I used as param was recognized =( .
If I use Encoding.Unicode tr.ReadLine() reads the whole file and convert it to Chinese for some reason.
private Dictionary<int, string> InitDictionary()
{
var d = new Dictionary<int, string>();
var sri = App.GetResourceStream(new Uri(fileDic, UriKind.Relative));
using (TextReader tr = new StreamReader(sri.Stream, Encoding.SOMEENCODINGHERE))
{
int i = 0;
string line;
while ((line = tr.ReadLine()) != null)
{
d.Add(i++, line);
}
}
return d;
}
If you really want ISO-Latin-1, you can use
But the normal Windows Western Europe code page is 1252:
Are you absolutely sure that’s the encoding for your stream though? These days it’s more common to use UTF-8. What’s generating your text resource?