How to use streamreader to read ascii 8 charecters

G

G.Esmeijer

Friends,

Want to read a textfile with characters that go above 7F ( ascii > 128) and
put the results line by line in a string to process it further
I used a streamreader to do so but the readline() methods in someway skipps
the characters > 127 .
I used the binary reader as well, same result.

string regel;
StreamReader sr = new StreamReader ( ImportFile, System.Yext.Unicode.UTF8);
While ( regel = sr.readline()) !=null)
{
I do something here
}

How to solve this?

Regards

Gerrit Esmeijer
 
G

G.Esmeijer

Yes you caught me. Fine OK Sorry
but now to the point.

I tried several things. What I would like is reading a string that consists
of characters them a degree sign en a diameter sing ( zero with a cross line
(alt-155 on your keyboard - I would not dare to say ascii-155) :) ); put
them in a string variable and store the result in a
field in a database. Leter I need to make lists with on them the same
characers againg.
And how about all those names with Umlauts (German) like ü , ö , ë etc.
There must be a way to simply read those chracters and store them in a
string variable.

Converting to ascii converts althose character > 127 into a ?
(ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùø£Ø×fáí etc)
For me, coming from vb6 this was no problem.
Now in C# I have till now not found a way to read these characters . In
spite of all the explenation tou are referring to.

PLEASE show me a piece of code that puts these Character into a string.
Regards, gerrit Esmeijer
 
J

Jon Skeet [C# MVP]

G.Esmeijer said:
Yes you caught me. Fine OK Sorry
but now to the point.

I tried several things. What I would like is reading a string that consists
of characters them a degree sign en a diameter sing ( zero with a cross line
(alt-155 on your keyboard - I would not dare to say ascii-155) :) ); put
them in a string variable and store the result in a
field in a database. Leter I need to make lists with on them the same
characers againg.
And how about all those names with Umlauts (German) like ü , ö , ë etc.
There must be a way to simply read those chracters and store them in a
string variable.

Absolutely - but where are you trying to read them from? What's teh
file format, if you're reading it from a file?
Converting to ascii converts althose character > 127 into a ?
(ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùø£Ø×fáí etc)

Yes, it would, as those characters aren't in ASCII.
For me, coming from vb6 this was no problem.
Now in C# I have till now not found a way to read these characters . In
spite of all the explenation tou are referring to.

PLEASE show me a piece of code that puts these Character into a string.

Have you tried Encoding.Default as I suggested?

Did you read the page I directed you to?
 
G

G.Esmeijer

Jon,
First I did not know want you ment by >> Default <<. Since you are referring
to it for the second time I got into the theory a bit more and see, the
Nickle fell and it worked.(among them is me) <<

Thanks
Gerrit

"Jon Skeet [C# MVP]" <[email protected]> schreef in bericht
G.Esmeijer said:
Yes you caught me. Fine OK Sorry
but now to the point.

I tried several things. What I would like is reading a string that consists
of characters them a degree sign en a diameter sing ( zero with a cross line
(alt-155 on your keyboard - I would not dare to say ascii-155) :) ); put
them in a string variable and store the result in a
field in a database. Leter I need to make lists with on them the same
characers againg.
And how about all those names with Umlauts (German) like ü , ö , ë etc.
There must be a way to simply read those chracters and store them in a
string variable.

Absolutely - but where are you trying to read them from? What's teh
file format, if you're reading it from a file?
Converting to ascii converts althose character > 127 into a ?
(ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùø£Ø×fáí etc)

Yes, it would, as those characters aren't in ASCII.
For me, coming from vb6 this was no problem.
Now in C# I have till now not found a way to read these characters . In
spite of all the explenation tou are referring to.

PLEASE show me a piece of code that puts these Character into a string.

Have you tried Encoding.Default as I suggested?

Did you read the page I directed you to?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top