473,809 Members | 2,826 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Pound symbol in a string

All,

When I use system.IO.Strea mWriter to write append a string to file that
contains the GBP pound symbol, I notice that it also appends an extra
character before the pond symbol. Yet when I examine the string character by
character in the command window, the extra character is not there.

For example:

Dim Line As New StringBuilder
Line.Append("Co st=£10")

Dim SW As StreamWriter
SW = File.AppendText ("C:\Test.tx t")

SW.WriteLine(Li ne(0))

SW.Close()

If I then view the contents of the file in notepad it shows:
Cost=£10

If I use a hex editor to view the contents of the file it shows:
43 6F 73 74 3D C2 A3 31 30 0D 0A

Obviously the 0D and 0A at the end are the Cr+Lf charactors, but I don't
understand where the C2 charactor has come from??
Sorry if this is a silly question - I'm really only used to VB6 - still
trying to get my head around dot net.

Cheers,

Paul.
Nov 21 '05 #1
3 6413
Paul,

"Paul Hadfield" <pa**@anon.co m> schrieb:
When I use system.IO.Strea mWriter to write append a string to file that
contains the GBP pound symbol, I notice that it also appends an extra
character before the pond symbol. Yet when I examine the string character
by character in the command window, the extra character is not there.

For example:

Dim Line As New StringBuilder
Line.Append("Co st=£10")

Dim SW As StreamWriter
SW = File.AppendText ("C:\Test.tx t")

SW.WriteLine(Li ne(0))
SW.Close()

If I then view the contents of the file in notepad it shows:
Cost=£10

If I use a hex editor to view the contents of the file it shows:
43 6F 73 74 3D C2 A3 31 30 0D 0A

Obviously the 0D and 0A at the end are the Cr+Lf charactors, but I don't
understand where the C2 charactor has come from??


'StreamWriter' uses UTF-8 as the default encoding. You can change the
encoding used to encode the text written to the file by specifying one of
the 'System.Text.En coding.*' encodings.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2
Paul,
As Herfried suggests StreamWriter by default uses UTF8. Normally you want to
use the encoding as specific under your regional settings in Control Panel,
which is Encoding.Defaul t.

Something like:

Imports System.Text

Dim writer As New StreamWriter("T est.txt", True, Encoding.Defaul t)

writer.WriteLin e("Cost=£10")

writer.Close()

Hope this helps
Jay

"Paul Hadfield" <pa**@anon.co m> wrote in message
news:%2******** *******@TK2MSFT NGP12.phx.gbl.. .
All,

When I use system.IO.Strea mWriter to write append a string to file that
contains the GBP pound symbol, I notice that it also appends an extra
character before the pond symbol. Yet when I examine the string character
by character in the command window, the extra character is not there.

For example:

Dim Line As New StringBuilder
Line.Append("Co st=£10")

Dim SW As StreamWriter
SW = File.AppendText ("C:\Test.tx t")

SW.WriteLine(Li ne(0))

SW.Close()

If I then view the contents of the file in notepad it shows:
Cost=£10

If I use a hex editor to view the contents of the file it shows:
43 6F 73 74 3D C2 A3 31 30 0D 0A

Obviously the 0D and 0A at the end are the Cr+Lf charactors, but I don't
understand where the C2 charactor has come from??
Sorry if this is a silly question - I'm really only used to VB6 - still
trying to get my head around dot net.

Cheers,

Paul.

Nov 21 '05 #3
Thats great - works a treat

Jay - you're a star!!!!

Cheers,
Paul.
"Jay B. Harlow [MVP - Outlook]" <Ja************ @msn.com> wrote in message
news:em******** ******@TK2MSFTN GP14.phx.gbl...
Paul,
As Herfried suggests StreamWriter by default uses UTF8. Normally you want
to use the encoding as specific under your regional settings in Control
Panel, which is Encoding.Defaul t.

Something like:

Imports System.Text

Dim writer As New StreamWriter("T est.txt", True, Encoding.Defaul t)

writer.WriteLin e("Cost=£10")

writer.Close()

Hope this helps
Jay

"Paul Hadfield" <pa**@anon.co m> wrote in message
news:%2******** *******@TK2MSFT NGP12.phx.gbl.. .
All,

When I use system.IO.Strea mWriter to write append a string to file that
contains the GBP pound symbol, I notice that it also appends an extra
character before the pond symbol. Yet when I examine the string character
by character in the command window, the extra character is not there.

For example:

Dim Line As New StringBuilder
Line.Append("Co st=£10")

Dim SW As StreamWriter
SW = File.AppendText ("C:\Test.tx t")

SW.WriteLine(Li ne(0))

SW.Close()

If I then view the contents of the file in notepad it shows:
Cost=£10

If I use a hex editor to view the contents of the file it shows:
43 6F 73 74 3D C2 A3 31 30 0D 0A

Obviously the 0D and 0A at the end are the Cr+Lf charactors, but I don't
understand where the C2 charactor has come from??
Sorry if this is a silly question - I'm really only used to VB6 - still
trying to get my head around dot net.

Cheers,

Paul.


Nov 21 '05 #4

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

Similar topics

4
25948
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
14
3291
by: Vic Russell | last post by:
Hi, I'm trying to get the British pound (£) symbol through LibXML and just get "£" instead. Any ideas? Vic
5
7971
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
6706
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
5174
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*.
5
3135
by: Jim Carlock | last post by:
(1) test.php?test_key=test_value $_SERVER returns /test/test.php $_SERVER returns /test/test.php?test_key=test+value $_SERVER returns test_key=test+value (2) test.php?test_key=test_value#test_internal_sublink $_SERVER returns /test/test.php $_SERVER returns /test/test.php?test_key=test+value
5
24089
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
1
3420
by: Darren Mansell | last post by:
Hi. I'm relatively new to python so please be gentle :) I'm trying to write a £ symbol to an MS SQL server using pymsssql . This works but when selecting the data back (e.g. using SQL management studio) the £ symbol is replaced with £ (latin capital letter A with circumflex). I can reproduce it like so:
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
9721
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9600
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
10376
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...
0
10114
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
9198
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
6880
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
5548
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...
0
5686
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3860
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.