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

StreamReader won't read pound-sign

When I use a StreamReader to read lines from a file, it seems to skip some
"special" characters like ?, æ, ø and å. How do I prevent it from doing
this? I know it works if the text file is in unicode but unfortunately this
is not a possibility for me in this case because I do not save the text
files myself and there are way too many to do manuel convertion.

Thanks in advance,
Per Rasmussen.
Sep 7 '06 #1
2 4826
Hi,

Per Rasmussen napisa³(a):
When I use a StreamReader to read lines from a file, it seems to skip some
"special" characters like ?, æ, ø and å. How do I prevent it from doing
this? I know it works if the text file is in unicode but unfortunately this
is not a possibility for me in this case because I do not save the text
files myself and there are way too many to do manuel convertion.

Thanks in advance,
Per Rasmussen.
You will need to set right encoding in a StreamReader
constructor or set the encoding detection.
I don't know what a code page you'll have to work with?
If you don't know that encoding you'll need to consider
of raw-byte reader-converter.

With regards
Marcin
Sep 7 '06 #2
Hi Per,

As Marcin said, the encoding is wrong. The default encoding for a
StreamReader is UTF8, but most likely you are reading something written
with ANSI encoding.

Try
StreamReader sr = new StreamReader(filename, Encoding.Default);
On Thu, 07 Sep 2006 11:00:57 +0200, Per Rasmussen <p@p.pwrote:
When I use a StreamReader to read lines from a file, it seems to skip
some
"special" characters like ?, æ, ø and å. How do I prevent it from doing
this? I know it works if the text file is in unicode but unfortunately
this
is not a possibility for me in this case because I do not save the text
files myself and there are way too many to do manuel convertion.

Thanks in advance,
Per Rasmussen.



--
Happy Coding!
Morten Wennevik [C# MVP]
Sep 7 '06 #3

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...
11
by: Tiger | last post by:
We can use seek() in the FileStream class,as we know. But I found that seek() is not work correctly in StreamReader. Who can tell me how to use seek() correctly in StreamReader? thanks a lot! I...
3
by: Rene | last post by:
The documentation has the following remark for the ReadBlock method of the StreamReader: "The method blocks until either count characters are read, or all characters have been read". What kind...
4
by: Astronomically Confused | last post by:
using System; using System.Collections; using System.IO; using System.Net; using System.Net.Sockets; using System.Threading; class HttpProcessor { private Socket s;
3
by: Arno | last post by:
Hi, I'm using TcpClient for communication between two PC running a small piece of software. The protocol used has been designed internally and is HTTP similar (command line, headers, body). A...
21
by: JoKur | last post by:
Hello, First let me tell you that I'm very new to C# and learning as I go. I'm trying to write a client application to communicate with a server (that I didn't write). Each message from the...
6
by: Jesper | last post by:
Hi, Im using a code snippet that reads a text file from disc and processes it using stream = new StreamReader(filename); Is it possible to assign a String instead of a file as the source of...
7
by: Mike Joseph | last post by:
I have a data file that was produced in MicroSoft Access. It's a table that was exported as a fixed format, sequential access ASCII file. It contains over 80,000 records. Basically, all the stats...
1
by: Pantelis Sotiropoulos | last post by:
Greetings! I'm opening a text file with as a StreamReader. The problem is when the file is used by another user or Windows, it won't open! When I double click the file it opens it. That's...
3
by: stumorgan | last post by:
I'm doing some USB communications in C# and am running into a minor annoyance. I'm using the Windows API CreateFile function to get a SafeFileHandle, which I then stuff into a FileStream and from...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.