Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 2.0 and Visual Studio. 2005 > .NET Framework 2.0
Password Reminder
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 Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 30th, 2009, 07:40 AM
Authorized User
 
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
Reply With Quote
  #2 (permalink)  
Old July 2nd, 2009, 07:40 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 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 -/

Think before you post: What have you tried?
Reply With Quote
  #3 (permalink)  
Old July 16th, 2009, 07:45 AM
Authorized User
 
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.
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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 12:15 PM
Converting Int -> ASCII silaros C++ Programming 1 June 5th, 2007 01: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 05:50 PM



All times are GMT -4. The time now is 04:28 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.