Reading from a text file, with non-English letters

S

Sonnich Jensen

Hi

I use the streamreader, as given here:

http://msdn.microsoft.com/en-us/library/db5x7c0d.aspx

However, when I get data from the ReadLine, it removes all the non-
English letters with "rectangles" as they are unknown characters.
Opening the file in notepad is ok.

I am now thinking, that I dont know the format of the file... however
I'd like to use unicode, as I have both Hungarian, Estonian texts and
other in the same file. We use that for i18n texts.

WBR
Sonnich
 
A

Arne Vajhøj

I use the streamreader, as given here:

http://msdn.microsoft.com/en-us/library/db5x7c0d.aspx

However, when I get data from the ReadLine, it removes all the non-
English letters with "rectangles" as they are unknown characters.
Opening the file in notepad is ok.

I am now thinking, that I dont know the format of the file... however
I'd like to use unicode, as I have both Hungarian, Estonian texts and
other in the same file. We use that for i18n texts.

C# will use unicode internally.

But when reading a file you need to specify the correct Encoding.

There are some StreamReader constructors that take an Encoding
argument.

Encoding.UTF8 and Encoding.Default are worth trying first.

Arne
 
S

Sonnich Jensen

C# will use unicode internally.

But when reading a file you need to specify the correct Encoding.

There are some StreamReader constructors that take an Encoding
argument.

Encoding.UTF8 and Encoding.Default are worth trying first.

Tak, det hjalp.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top