writing the degree symbol to a text file

Posted on 2007-07-20
Last Modified: 2013-11-07

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?

Question by:JosP
    LVL 10

    Expert Comment

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

    Expert Comment

    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)


    LVL 27

    Accepted Solution

    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)



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
    Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
    The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now