473,624 Members | 2,258 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("i nput.txt");
StreamWriter sw = new StreamWriter("o utput.txt");
string Line;
char [] delimiter = {'*'};
while((Line = sr.ReadLine()) != null)
{
string[] Fields;
Fields = Line.Split(deli miter);
foreach (string thisField in Fields)
{
sw.WriteLine(th isField);
}
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 6876
Hold onnnnnnn....... ...

StreamReader sr = new StreamReader("i nput.txt", System.Text.Enc oding.UTF7);

Nirosh.

"Anthony" <An*****@discus sions.microsoft .com> wrote in message
news:E8******** *************** ***********@mic rosoft.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("i nput.txt");
StreamWriter sw = new StreamWriter("o utput.txt");
string Line;
char [] delimiter = {'*'};
while((Line = sr.ReadLine()) != null)
{
string[] Fields;
Fields = Line.Split(deli miter);
foreach (string thisField in Fields)
{
sw.WriteLine(th isField);
}
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("i nput.txt", System.Text.Enc oding.UTF7);


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

--
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
Anthony <An*****@discus sions.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("i nput.txt");
StreamWriter sw = new StreamWriter("o utput.txt");
string Line;
char [] delimiter = {'*'};
while((Line = sr.ReadLine()) != null)
{
string[] Fields;
Fields = Line.Split(deli miter);
foreach (string thisField in Fields)
{
sw.WriteLine(th isField);
}
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.Defaul t 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.co m>
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.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
Champika Nirosh <te**@test.lk > wrote:
Hold onnnnnnn....... ...

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

--
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
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.co m>
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("i nput.txt");
StreamWriter sw = new StreamWriter("o utput.txt");
string Line;
char [] delimiter = {'*'};
while((Line = sr.ReadLine()) != null)
{
string[] Fields;
Fields = Line.Split(deli miter);
foreach (string thisField in Fields)
{
sw.WriteLine(th isField);
}
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
25920
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 well as
4
16806
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 excuse any typos). This page is not a production page - I created it just to try and solve the £ sign problem I am having. When I put the pound sign (£) into the input box and submit the form,
5
7959
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 application that is processing the output complains about the character. Both the strings and the application are using UTF-8. If you view the text in Notepad the pound symbol looks fine, but if you view the hex, there is a character preceding the...
2
6685
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 managed to get "lastRSS" which is a simple RSS parser.
3
5152
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 modified u in place of the pound symbol. Why is that? If I output the ASCII code of the pound symbol it outputs just fine--but not when in a char*.
4
13997
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 what is causing it? regards marc
5
24042
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 will be appreciated. thanks and regards Nanda
8
32785
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. googling, would appreciate some detailed information.
0
2513
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 encoded in the source that I am trying to extract with the WebRequest and WebResponse objects. The page is using a charset of iso-8859-1 which I think is the problem as my object is using UTF-8. I have created two test pages one using UTF-8 the...
0
8170
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8619
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8334
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
7158
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5561
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
4173
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2604
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
1
1784
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1482
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.