|
|
 |
| .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.
|
 |

June 30th, 2009, 08:40 AM
|
|
Authorized User
|
|
Join Date: Jan 2008
Location: Islamabad, Punjab, Pakistan.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

July 2nd, 2009, 08:40 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 1,340
Thanks: 0
Thanked 26 Times in 26 Posts
|
|
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 -/
|

July 16th, 2009, 08:45 AM
|
|
Authorized User
|
|
Join Date: Jan 2008
Location: Islamabad, Punjab, Pakistan.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |