473,320 Members | 1,848 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,320 software developers and data experts.

How to use streamreader to read ascii 8 charecters

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

Nov 16 '05 #1
4 3073
G.Esmeijer <ge****@nomail.nl> wrote:
Want to read a textfile with characters that go above 7F ( ascii > 128)


There's no such thing as ASCII > 128.

Perhaps you mean Encoding.Default?

See http://www.pobox.com/~skeet/csharp/unicode.html

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
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




"Jon Skeet [C# MVP]" <sk***@pobox.com> schreef in bericht
news:MP************************@msnews.microsoft.c om...
G.Esmeijer <ge****@nomail.nl> wrote:
Want to read a textfile with characters that go above 7F ( ascii > 128)


There's no such thing as ASCII > 128.

Perhaps you mean Encoding.Default?

See http://www.pobox.com/~skeet/csharp/unicode.html

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #3
G.Esmeijer <ge****@nomail.nl> wrote:
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?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4
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.
Things that are obvious for some people do not need to be that for other
(among them is me) <<

Thanks
Gerrit

"Jon Skeet [C# MVP]" <sk***@pobox.com> schreef in bericht
news:MP************************@msnews.microsoft.c om...
G.Esmeijer <ge****@nomail.nl> wrote: 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?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jason Gleason | last post by:
I'm having a problem with the streamreader class. When i read out of a file, characters like é are taken out when i do readline. Why does this happen? When i switch the encoding to ascii, it...
4
by: G.Esmeijer | last post by:
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...
2
by: Keith Kingsley | last post by:
I'm using a StreamReader to read in several lines from an ASCII file. I'd like to know the StreamReader's "true" position-- that is, the number of bytes into the file that the StreamReader has...
0
by: Ed West | last post by:
Hi, I am trying to read a file, make changes, and write it to a new file. The original file has the copyright character © which is ascii 169 I believe, which is more than 7 bits. I am using...
3
by: pabelard | last post by:
I am reading from a file and trying to find out if it has characters above ASCII 127 in it. My sample file does have several of these characters. However, the streamreader seems to skip over...
7
by: sweetpotatop | last post by:
Hello, I have a txt file which has a few lines of special characters: This is A line from the text file: ...
0
by: rajana | last post by:
Dear All, We have Ansi file with german characters (Ä / Ø) , We are using Streamreader to read the contents of the file. But Readline() not able to read the German characters. We tried all...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.