p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > .NET > .NET 2.0 and Visual Studio. 2005 > .NET Framework 2.0
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
.NET Framework 2.0 For discussion of the Microsoft .NET Framework 2.0.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 2.0 section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 30th, 2009, 08:40 AM
Authorized User
Points: 71, Level: 1
Points: 71, Level: 1 Points: 71, Level: 1 Points: 71, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Islamabad, Punjab, Pakistan.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Converting ASCII Text file to Unicode

Hi,
The problem i am having is that i have to process CSV files into the database. My CSV files are in ASCII format as provided by customer. These files can contain german characters so therefor i need to save these in unicode format so that i can read them and update in SQLServer.
Currently what i do is that i open the CSV file and save it in Unicode format manually and all processing is done alright. What i have to do is to write an application which will process these files automatically. So want the saving to be done by the application.
I am using C#.Net as my programming language.
I have searched the web and different forums for this. The solution that most of the forums have provided is to use StreamReader and StreamWriter classes and use Encoding.unicode or Encoding.UTF-8. The file is saved alright but german characters are still not been converted to unicode.
I have tried almost all ways i found on internet for this purpose to try saving file in unicode but havent succeeded yet.
Will any body tell me that what mistake i am making that german characters are not been converted to unicode.
Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old July 2nd, 2009, 08:40 AM
samjudson's Avatar
Friend of Wrox
Points: 4,336, Level: 27
Points: 4,336, Level: 27 Points: 4,336, Level: 27 Points: 4,336, Level: 27
Activity: 40%
Activity: 40% Activity: 40% Activity: 40%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 1,340
Thanks: 0
Thanked 26 Times in 26 Posts
Default

The ASCII standard only contains 128 characters, therefore what you are calling an 'ASCII' file is not. You are probably referring to ISO 8859-1 (commonly known as 'Latin-1') which contains all the latin characters required to write the german language.

The thing is, unicode is a superset of both ASCII and ISO 8859-1, so in theory a valid ASCII file is also a valid unicode (UTF-8) file.

UTF-16 and UTF-32 are different in the way they represent their characters, so would not be valid ASCII documents.

Without seeing the files in question it is hard to make any further comments.
__________________
/- Sam Judson : Wrox Technical Editor -/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old July 16th, 2009, 08:45 AM
Authorized User
Points: 71, Level: 1
Points: 71, Level: 1 Points: 71, Level: 1 Points: 71, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Islamabad, Punjab, Pakistan.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem Reading the unicode file

Thanks Sam for reply. I have that problem solved. I had no problem in saving the file. File was saved alright. Problem was when i was reading the file. When reading i was using System.IO.File.ReadAllText method. There it was problem. I specified Encoding.Default when reading the file and it succeded.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
unicode and ascii characters sudhanshu631 BOOK: Ivor Horton's Beginning Visual C++ 2008 ISBN: 978-0-470-22590-5 0 May 24th, 2009 01:15 PM
Converting Int -> ASCII silaros C++ Programming 1 June 5th, 2007 02:12 AM
Get UNICODE or ASCII Value of a character Eyob_the_pro C# 0 January 10th, 2007 03:42 AM
Write ASCII text file muklee C# 1 December 12th, 2004 09:40 PM
Reading ASCII data from text file. LordBeholder VB How-To 2 June 25th, 2004 06:50 PM



All times are GMT -4. The time now is 08:46 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc