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 / Languages / C# / April 2008

Tip: Looking for answers? Try searching our database.

UTF encoding and StreamWriter

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
arunairs@gmail.com - 29 Apr 2008 05:00 GMT
Hi,
 After writing the £ (pound sterling) symbol to a file using
StreamWriter using the default encoding UTF8, when I retrieve it the
file symbol £ gets changed.  But when I use Encoding.Default in the
StreamWriter, I am able to retrieve the symbol without any issue.

Can you tell me why this is so? Microsoft recommend using UTF8 for
encoding, but it does not seem to work in this case.

thanks,

Arun
Morten Wennevik [C# MVP] - 29 Apr 2008 06:10 GMT
Hi Arun,

You are not saving and reading the file using the same Encoding.  

If you do not specify encoding the StreamWriter/Reader will default to UTF8,
but other applications often default to the code page used by your current
locale, Encoding.Default (ANSI).  For instance, Notepad uses ANSI encoding if
not told otherwise.

Check your reading/writing code.  If both reading and writing uses UTF8, do
other parts of your program, or other applications, create the file in
question?

Signature

Happy Coding!
Morten Wennevik [C# MVP]

> Hi,
>   After writing the £ (pound sterling) symbol to a file using
[quoted text clipped - 8 lines]
>
> Arun

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.