473,466 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to handle every character within a 'StreamReader'?

Hi.

I want to make a script which reads a file and shows its contents:
------------
using (StreamReader sr = new
StreamReader(objResponse.GetResponseStream(),
System.Text.Encoding.GetEncoding("iso-8859-15")))
{
result = sr.ReadToEnd();
sr.Close();
}
return result;
-----------

It works fine, but it doesn't show euro symbol ('x80') correctly.

I want to handle every character and, when it's 'x80' I can convert it
to 'EUR' word.

How can I handle every character within a 'StreamReader'?

Thank you very much,
--F

Feb 3 '06 #1
1 1598
fr**********@usa.com wrote:
I want to make a script which reads a file and shows its contents:
------------
using (StreamReader sr = new
StreamReader(objResponse.GetResponseStream(),
System.Text.Encoding.GetEncoding("iso-8859-15")))
{
result = sr.ReadToEnd();
sr.Close();
}
return result;
-----------

It works fine, but it doesn't show euro symbol ('x80') correctly.
Have you worked out whether that's due to how you're reading it or how
you're displaying it?
I want to handle every character and, when it's 'x80' I can convert it
to 'EUR' word.

How can I handle every character within a 'StreamReader'?


Well, you could read a character at a time - but it may be
significantly more efficient to read a chunk at a time (using
Read(buffer, index, size)) and only act on buffers which have
problematic parts in them.

Alternatively, unless the files are particularly big, you could read it
as you already are doing, and then just use String.Replace to replace
the Euro cahracter with "EUR". Not as efficient, but really simple.

Jon

Feb 3 '06 #2

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

Similar topics

6
by: R.Wieser | last post by:
Hello All, I'm trying to get a "Virtual Listbox" to work. I've currently got a form, and used CreateWindowExA to create a ListBox with the LBS_OWNERDRAWFIXED and LBS_NODATA flags on it. I've...
2
by: Shawn Anderson | last post by:
Anyone know how I can get a Win32 HANDLE from a StreamReader or StreamWriter? I want to work with some I/O using Win32 APIs, but I would like to attach the I/O to a .NET Stream class. Any...
4
by: Pujo Aji | last post by:
Hello, I would like to read file during runtime(the other third party vendor write the program and my program read it every second). I can't do it until the third party vendor stop writing it....
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...
37
by: Zhiv Kurilka | last post by:
Hi, I have a text file with following content: "((^)|(.* +))§§§§§§§§" if I read it with: k=System.IO.StreamReader( "file.txt",System.Text.Encoding.ASCII); k.readtotheend()
3
by: CyberSpyders | last post by:
Hi, I have an ASP.Net website, which allows users to upload a file which is then inserted into a database. This is all fine until it reads a line with the string +Anu in it. It transforms...
10
by: lamxing | last post by:
Dear all, I've spent a long time to try to get the xmldocument.load method to handle UTF-8 characters, but no luck. Every time it loads a document contains european characters (such as the...
7
by: billsahiker | last post by:
if an xml file specifies an encoding, e.g., utf16, do xml browsers and xml editors read and verify each character in the file to make sure it is utf16? and throw an error if it is not, or. do they...
10
by: Paul W | last post by:
Hi all, I have an application that reads data in from a text file and stores it in a database. My problem is that there are some characters in the file that aren't being handled properly. For...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.