special characters

rfazendeiro

Centurion
Joined
Mar 8, 2004
Messages
110
Hi to all,

I'm currently making a app that has to read 2 files and combine it all in one. The information is layout in lines. Something like this

000222333 23222323 Street number 27 6700-200
003343344 34556324 The Mall 24 5400-200
000003322 32233233 Street Hólând 33 3432-233

So i go through the lines and take the information. That easy because i have the position of each information so i can take it with Substring. Something like this

Code:
string value = string.Empty;

StreamReader sr = new StreamReader(@"C:\File.txt");
string sLineApolices = null;

while((sLineApolices = srApolices.ReadLine()) != null)
{
     value = sline.Substring(25, 38);
}

in this example i take the street name. All is fine except, as you can see, the last street name has an accentuated character "Street Hólând".

This is where the problem is. It appears that substring method skips this characters. So in this case value has this information
Street Hlnd 3

How can i make it recognize these character?
 
When you create the stream reader you can specify then character encoding to use rather than letting it figure it out by itself. Just look at the overloads for it's constructor.
 
Back
Top