473,399 Members | 3,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

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

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
2 2125
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

23
by: Invalid User | last post by:
While trying to print a none empty list, I accidentaly put an "else" statement with a "for" instead of "if". Here is what I had: if ( len(mylist)> 0) : for x,y in mylist: print x,y else:...
68
by: Marco Bubke | last post by:
Hi I have read some mail on the dev mailing list about PEP 318 and find the new Syntax really ugly. def foo(x, y): pass I call this foo(1, 2), this isn't really intuitive to me! Also I...
14
by: David B. Held | last post by:
I wanted to post this proposal on c.l.c++.m, but my news server apparently does not support that group any more. I propose a new class of exception safety known as the "smart guarantee". ...
15
by: Robert Allan Schwartz | last post by:
I've heard the phrase "Miranda function" used to refer to the 6 member functions supplied by the compiler: default constructor copy constructor destructor operator= operator& const operator&
1
by: knocte | last post by:
Hello group. In the following testcase I attach to the final of the message, I have two questions: 1) According to comment # 1, how can I pass an argument to the function that way? 2)...
72
by: Paminu | last post by:
In math this expression: (a < b) && (b < c) would be described as: a < b < c But why is it that in C these two expressions evaluate to something different for the same values of a, b and...
0
by: Greg Bacchus | last post by:
Hi, Does anyone know how to make "special" folder apear under "My Computer". Like the Control Panel, or when a Camera appears when plugged in. And have it so that the contents of that folder is not...
14
by: Alf P. Steinbach | last post by:
Not yet perfect, but: http://home.no.net/dubjai/win32cpptut/special/pointers/ch_01.pdf http://home.no.net/dubjai/win32cpptut/special/pointers/ch_01_examples.zip To access the table of...
5
by: Peter Hansen | last post by:
I'm investigating a puzzling problem involving an attempt to generate a constant containing an (IEEE 754) "infinity" value. (I understand that special float values are a "platform-dependent...
34
by: arnuld | last post by:
what is the difference between these 2: char name = "hackers"; char* name = "hackers";
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.