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

Missing £ (pound) sign

When using StreamReader/Writer to process an input text file to an output
text file the pound signs (£) simply disappear. Sample code:

StreamReader sr = new StreamReader("input.txt");
StreamWriter sw = new StreamWriter("output.txt");
string Line;
char [] delimiter = {'*'};
while((Line = sr.ReadLine()) != null)
{
string[] Fields;
Fields = Line.Split(delimiter);
foreach (string thisField in Fields)
{
sw.WriteLine(thisField);
}
sw.WriteLine("******************");
}
sr.Close();
sw.Close();

Any ideas folks? I'm pulling my hair out and have very little to spare!
--
Many thanks for any help
Anthony Ward
Nov 16 '05 #1
6 6848
Hold onnnnnnn..........

StreamReader sr = new StreamReader("input.txt", System.Text.Encoding.UTF7);

Nirosh.

"Anthony" <An*****@discussions.microsoft.com> wrote in message
news:E8**********************************@microsof t.com...
When using StreamReader/Writer to process an input text file to an output
text file the pound signs (£) simply disappear. Sample code:

StreamReader sr = new StreamReader("input.txt");
StreamWriter sw = new StreamWriter("output.txt");
string Line;
char [] delimiter = {'*'};
while((Line = sr.ReadLine()) != null)
{
string[] Fields;
Fields = Line.Split(delimiter);
foreach (string thisField in Fields)
{
sw.WriteLine(thisField);
}
sw.WriteLine("******************");
}
sr.Close();
sw.Close();

Any ideas folks? I'm pulling my hair out and have very little to spare!
--
Many thanks for any help
Anthony Ward

Nov 16 '05 #2
Champika Nirosh <te**@test.lk> wrote:
Hold onnnnnnn..........

StreamReader sr = new StreamReader("input.txt", System.Text.Encoding.UTF7);


Almost certainly not. UTF7 is a pretty rarely used encoding, in my
experience.

--
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
Anthony <An*****@discussions.microsoft.com> wrote:
When using StreamReader/Writer to process an input text file to an output
text file the pound signs (?) simply disappear. Sample code:

StreamReader sr = new StreamReader("input.txt");
StreamWriter sw = new StreamWriter("output.txt");
string Line;
char [] delimiter = {'*'};
while((Line = sr.ReadLine()) != null)
{
string[] Fields;
Fields = Line.Split(delimiter);
foreach (string thisField in Fields)
{
sw.WriteLine(thisField);
}
sw.WriteLine("******************");
}
sr.Close();
sw.Close();

Any ideas folks? I'm pulling my hair out and have very little to spare!


What encoding is the file in? It's probably in the default encoding for
the system, in which case, specifying Encoding.Default in the
constructor for the StreamReader (and StreamWriter) should fix the
problem.

Note that using statements would make your code more robust - currently
you're not closing the reader/writer if an exception is thrown.

--
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
mmm I guess you are correct..

but what is happening with ur mail client .. what encoding does it use...

I mean to convert pound to "=A3"
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Champika Nirosh <te**@test.lk> wrote:
Hold onnnnnnn..........

StreamReader sr = new StreamReader("input.txt",
System.Text.Encoding.UTF7);
Almost certainly not. UTF7 is a pretty rarely used encoding, in my
experience.

--
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
Champika Nirosh <te**@test.lk> wrote:
mmm I guess you are correct..

but what is happening with ur mail client .. what encoding does it use...

I mean to convert pound to "=A3"


Yes, mail clients use UTF-7 sometimes, but I think they're virtually
the only things that *do* use UTF-7.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #6
Following your observations I convert the input text file toUnicode (simply
saving in notepad) and it all worked a dream - silly me of course, now I see
the light - so once again, many thanks, Anthony

"Anthony" wrote:
When using StreamReader/Writer to process an input text file to an output
text file the pound signs (£) simply disappear. Sample code:

StreamReader sr = new StreamReader("input.txt");
StreamWriter sw = new StreamWriter("output.txt");
string Line;
char [] delimiter = {'*'};
while((Line = sr.ReadLine()) != null)
{
string[] Fields;
Fields = Line.Split(delimiter);
foreach (string thisField in Fields)
{
sw.WriteLine(thisField);
}
sw.WriteLine("******************");
}
sr.Close();
sw.Close();

Any ideas folks? I'm pulling my hair out and have very little to spare!
--
Many thanks for any help
Anthony Ward

Nov 16 '05 #7

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

Similar topics

4
by: Robert Zierhofer | last post by:
hi there, it seems as if i can´t convert the euro and pound sign to their html equivalents. i tried eregi_replace("€", "&euro;", $haystack); eregi_replace("£", "&pound;", $haystack); as...
4
by: ben | last post by:
Hi all, I have a simple PHP page that takes values from a form and puts them in a database (MySQL). The code is in a file test.php, which I have typed in at the bottom of this post (please...
5
by: Waldy | last post by:
Hi there, I am using the .Net XML Serialization classes to create XML strings. This has been working fine up until the point that one of the strings contained a pound sterling symbol. The...
2
by: junk | last post by:
Hi, Sorry if this has been asked before, and apologise if this is the wrong NG. I am using PHP 5.0.5 and Apache 2.0.54 in a Win2k environment. Lately I have been playng with RSS feeds. I...
3
by: quat | last post by:
Hi, I have a char* string where I assigned a string literal with the British pound symbol, which is included in the extended ASCII, at least on my OS. However, when I cout the string, I get a...
4
by: monomaniac21 | last post by:
hi im outputting text from a db and where a £ sign has been entered a ? character appears instead which i cant seem to get rid of with a simple str_replace. is their a way to get rid of it? and...
5
by: ramaswamynanda | last post by:
Hello, I have a currency field on my form. The default formats for this field are dollar, euro. There is no pound symbol.....How do i put in a currency format, having the pound sign. Any help...
8
by: davoti | last post by:
Hi, I never truly understand how a macro with ## work in C, for example, if I define #define X X##_YZ what and how does this translated into after compilation? Can't find similar info....
0
by: RobR2009 | last post by:
I am having trouble with a C# proxy page I am writing which allows me to do cross domain AJAX calls with Javascript. The problem is with certain pages that contain pound signs £ that are not HTML...
1
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: 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...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.