Text file import and Danish characters

  • Thread starter Thread starter Simon B. Nielsen
  • Start date Start date
S

Simon B. Nielsen

I have a text fil with foreign characters I need to import.

I read it using this:

StreamReader sr = new StreamReader("@import/user.dat",
System.Text.Encoding.GetEncoding(850));
while(sr.Peek() > -1)
{
string myLine = sr.ReadLine();
myLine.Replace("ø", "ø") // Just an example
Console.WriteLine(myLine);
}

Problem is that "ø" is never replaced with "ø" when calling my
Import.exe. If I on the other hand calls Import.exe > output.log I see the
"ø" correctly. Fact is that the "ø" is never replaced.

Any ideas?
 
Simon B. Nielsen said:
I have a text fil with foreign characters I need to import.

I read it using this:

StreamReader sr = new StreamReader("@import/user.dat",
System.Text.Encoding.GetEncoding(850));
while(sr.Peek() > -1)
{
string myLine = sr.ReadLine();
myLine.Replace("ø", "ø") // Just an example
Console.WriteLine(myLine);
}

Problem is that "ø" is never replaced with "ø" when calling my
Import.exe. If I on the other hand calls Import.exe > output.log I see the
"ø" correctly. Fact is that the "ø" is never replaced.

Any ideas?

See http://www.pobox.com/~skeet/csharp/debuggingunicode.html
 
Back
Top