By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,574 Members | 1,205 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,574 IT Pros & Developers. It's quick & easy.

Re: "Special" or Non-English characters in Strings

P: n/a
John Straumann wrote:
However there are characters in the file that are non-english, and when
I process the file these characters are getting replaced by blanks. For
example:

Barkóczi Miklós

becomes

Bark�czi, Mikl�s

Can anyone tell me how I can process the file and retain the characters?
I tried Unicode but that did not work...
Ask the author of the file how it is encoded. Then use that encoding to
read the file. For instance if it is UTF-8 encoded then use
new StreamReader("file.txt", Encoding.UTF8)
if it is Windows-1252 encoded then use
new StreamReader("file.txt", Encoding.GetEncoding(1252))
You could also try
new StreamReader("file.txt", Encoding.Default)

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Sep 30 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi Martin and Jon:

Thank you for your messages. The data was actually sent to me in the body of
an email message, which I then copied into a CSV file. Should I do something
different?

John.

"Martin Honnen" <ma*******@yahoo.dewrote in message
news:uE**************@TK2MSFTNGP02.phx.gbl...
John Straumann wrote:
>However there are characters in the file that are non-english, and when I
process the file these characters are getting replaced by blanks. For
example:

Barkóczi Miklós

becomes

Bark�czi, Mikl�s

Can anyone tell me how I can process the file and retain the characters?
I tried Unicode but that did not work...

Ask the author of the file how it is encoded. Then use that encoding to
read the file. For instance if it is UTF-8 encoded then use
new StreamReader("file.txt", Encoding.UTF8)
if it is Windows-1252 encoded then use
new StreamReader("file.txt", Encoding.GetEncoding(1252))
You could also try
new StreamReader("file.txt", Encoding.Default)

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Sep 30 '08 #2

P: n/a
John Straumann wrote:
Thank you for your messages. The data was actually sent to me in the
body of an email message, which I then copied into a CSV file. Should I
do something different?
Well how exactly to you copy into a CSV file? If you do that in a text
editor and then save to CSV with the text editor then make sure you
check the encoding the text editor uses to save and then use that
encoding in your .NET code as shown in my previous post.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Sep 30 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.