473,881 Members | 1,746 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 6898
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
25953
by: Robert Zierhofer | last post by:
hi there, it seems as if i cant convert the euro and pound sign to their html equivalents. i tried eregi_replace("", "&euro;", $haystack); eregi_replace("", "&pound;", $haystack); as well as
4
16818
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
7978
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
6709
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
5181
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
14004
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
24099
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
32810
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
2523
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
9776
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
10724
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
10825
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
10403
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9556
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 projectplanning, coding, testing, and deploymentwithout 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...
1
7953
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 presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5781
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4598
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
2
4198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.