Re: Pound symbol in a string

From: Herfried K. Wagner [MVP] (hirf-spam-me-here_at_gmx.at)
Date: 02/25/05


Date: Fri, 25 Feb 2005 15:02:13 +0100

Paul,

"Paul Hadfield" <paul@anon.com> schrieb:
> When I use system.IO.StreamWriter 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("Cost=£10")
>
> Dim SW As StreamWriter
> SW = File.AppendText("C:\Test.txt")
>
> SW.WriteLine(Line(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.Encoding.*' encodings.

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


Relevant Pages

  • Re: file delete routine is intermittent
    ... >> terminator character to every string. ... > Only when you pass a string as a parameter. ... VB does NOT automatically append a null ...
    (microsoft.public.vb.winapi)
  • Re: file delete routine is intermittent
    ... >>> terminator character to every string. ... >> Only when you pass a string as a parameter. ... >> character to string members of structures so you must append the null ...
    (microsoft.public.vb.winapi)
  • Re: Append characters to file name to establish uniqueness
    ... I am trying to keep a set of files online and append a character ... string to each file in order to establish uniqueness to each file name ...
    (comp.os.vms)
  • Re: awk get length of pattern and append text
    ... I want to look at each line of a file and get the length of a string ... to 1 character in length then append FORENAME1_INITIAL to the end of ... then it must be an initial then append the appropriate text to the end ...
    (comp.lang.awk)
  • Pound symbol in a string
    ... When I use system.IO.StreamWriter to write append a string to file that ... contains the GBP pound symbol, I notice that it also appends an extra ... Yet when I examine the string character by ...
    (microsoft.public.dotnet.languages.vb)