So I have this foreign namebank in a textfile that I read from and throw into a dat开发者_运维技巧a 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?
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.
精彩评论