471,347 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,347 software developers and data experts.

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 1541
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Shawn Anderson | last post: by
4 posts views Thread by Pujo Aji | last post: by
37 posts views Thread by Zhiv Kurilka | last post: by
3 posts views Thread by CyberSpyders | last post: by
7 posts views Thread by billsahiker | last post: by
10 posts views Thread by Paul W | last post: by

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.