Link to home
Start Free TrialLog in
Avatar of JosP
JosP

asked on

writing the degree symbol to a text file

Hi,

I'm tring to write a string to a plain text file. The string contains ASCII code 176, the degree symbol. In the text file it is written as ° (capital A circumflex accent and then the degree symbol).

How can I just write the degree symbol? I suspect it has something to do with character sets?

TIA,
JosP
Avatar of athapa
athapa

If you are using StreamWriter then you can specify encoding. Something like "iso-8859-1" should work for usual plain text.
You can write it out specifying Unicode encoding.  Here's an example:

        Dim character As Char = Chr(176)

        Dim path As String = "c:\temp\test.out"

        Dim sw As New StreamWriter(path, False, System.Text.Encoding.Unicode)
        sw.WriteLine(character)
        sw.Close()

        MsgBox("Done")

ASKER CERTIFIED SOLUTION
Avatar of VBRocks
VBRocks
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial