views:

30

answers:

1

So I have this foreign namebank in a textfile that I read from and throw into a data table. The "string" datatype doesn't recognize the foreign letters. I am using a textreader/streamreader to read the text file line by line (one line per name)

What is in the textfile -> What shows up in the database(traced it to the string)

Szilveszter Kárpáthy -> Szilveszter K�rp�thy

Szalók Szôlôsy -> Szal�k Sz�l�sy

Im using nvarchar, but the mistranslation is happening from the declaration of the name to string. Any ideas to why?

+3  A: 

You may want to look at the overload StreamReader(Stream stream, Encoding encoding) if your file is not UTF8 and specify the encoding of the file.

To check if the file is read correctly, put a breakpoint in the code and check the content of the variables before storing them to the database. By doing this you can determine if the strings were decoded wrong from the file or if the encoding error occurs when saving to the database.

Albin Sunnanbo
what Encoding is the normal .txt file in Windows? UTF-8 isn't cutting it.
Mike
I got it, StreamReader(Stream stream, Encoding.Default) worked. Thanks! :)
Mike