[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

writing the degree symbol to a text file

Posted on 2007-07-20
3
Medium Priority
?
1,393 Views
Last Modified: 2013-11-07
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
0
Comment
Question by:JosP
  • 2
3 Comments
 
LVL 10

Expert Comment

by:athapa
ID: 19533017
If you are using StreamWriter then you can specify encoding. Something like "iso-8859-1" should work for usual plain text.
0
 
LVL 27

Expert Comment

by:VBRocks
ID: 19533092
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")

0
 
LVL 27

Accepted Solution

by:
VBRocks earned 1000 total points
ID: 19533273
Here's the same thing, with it used in a sentence.  View it in Notepad, and you'll see it worked correctly.

        Dim str As String = "The temperature in Albuquerue, NM is about 90" & Chr(176) & " today."

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

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

        MsgBox("Done")

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question