473,785 Members | 2,219 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Uni code.UTF8);
While ( regel = sr.readline()) !=null)
{
I do something here
}

How to solve this?

Regards

Gerrit Esmeijer

Nov 16 '05 #1
4 2224
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.Defaul t?

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

--
Jon Skeet - <sk***@pobox.co m>
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.co m> schreef in bericht
news:MP******** *************** *@msnews.micros oft.com...
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.Defaul t?

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

--
Jon Skeet - <sk***@pobox.co m>
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.Defaul t as I suggested?

Did you read the page I directed you to?

--
Jon Skeet - <sk***@pobox.co m>
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.co m> schreef in bericht
news:MP******** *************** *@msnews.micros oft.com...
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.Defaul t as I suggested?

Did you read the page I directed you to?

--
Jon Skeet - <sk***@pobox.co m>
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
2390
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 replaces those characters with a question mark. How do i get them to read correctly from a file? So the character is correctly read into the .net program?
4
3104
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 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);
2
13005
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 read. I thought about using MyStreamReader.BaseStream.Position, but this always seems to return a multiple of the StreamReader's buffer size (which seems natural-- as I understand it the StreamReader reads from the underlying stream in discrete...
0
326
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 typical StreamReader object to read in the file, but it is not getting it correctly. If I make the encoding type Ascii, it turns it into a question mark. If I use UTF7 or UTF8, it ignores it. Unicode was jibberish. Any ideas? Here is the file I...
3
3798
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 them. Even if I read in lines and then write them out to another file, the high ASCII number characters disappear. My code:
7
2152
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: ٦-ŧُʍѥޘ²ů'ۣб'с ',,طꎏЏ׮ When I use sr.ReadLine (where "sr As StreamReader"), it is not giving me this line
0
2362
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 possibilities of calling the streamreader, but nothing worked. Dim sr As StreamReader = New StreamReader(Filename, System.Text.Encoding.Default, True) Dim sr As StreamReader = New StreamReader(Filename, _System.Text.Encoding.ASCII, False, 512)
0
9646
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
10346
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10096
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9956
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7504
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6742
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5386
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5514
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4055
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.