Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / .NET SDK / September 2004

Tip: Looking for answers? Try searching our database.

Ascii --> UTF8 and Excel trouble

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chad Chisholm - 14 Sep 2004 06:04 GMT
I'm having trouble with an ascii character...

°

...getting turned into ...

°

...when I write it to a file and open in Excel.  It looks fine in
notepad, but excel mucks it up. I can only guess it's a Ascii to UTF8
problem.

Does anyone have any idea, or perhaps a lesson on strings they'd like
to share?

Thanks,
Chad
Joerg Jooss - 14 Sep 2004 07:03 GMT
> I'm having trouble with an ascii character...
>
[quoted text clipped - 10 lines]
> Does anyone have any idea, or perhaps a lesson on strings they'd like
> to share?

This is not an ASCII character (ASCII is only 7 bit). It is probably from an
8 bit extension of ASCII such as Windows-1252 or ISO-8859-1. Can you post
your code?

Cheers,

Signature

Joerg Jooss
joerg.jooss@gmx.net

Chad Chisholm - 17 Sep 2004 06:01 GMT
Yes. It's UTF8 encoding, I beleive.  Here is my code:

class Class1
{
    public static void Main(string[] args)
    {
        string degree = ("°");
        string sFile = "testingAscii.csv";
        System.IO.StreamWriter writer =
            System.IO.File.CreateText(sFile);
       
        try
        {
            writer.Write(degree);
        }
        finally
        {
            writer.Close();
        }
        System.Diagnostics.Process.Start(sFile);
    }
}

Thanks for any advice.
Hans - 23 Sep 2004 14:49 GMT
try

  System.IO.StreamWriter writer = new StreamWriter(sFile,
System.Text.Encoding.Default);

By using System.Text.Encoding.Default, the writer will use the system's
current ASNI code page.

Hans

> Yes. It's UTF8 encoding, I beleive.  Here is my code:
>
[quoted text clipped - 20 lines]
>
> Thanks for any advice.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.