This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Java in General and the fly likes Problem in writing extended ASCII characters into a file in japanese machines Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "Problem in writing extended ASCII characters into a file in japanese machines" Watch "Problem in writing extended ASCII characters into a file in japanese machines" New topic
Author

Problem in writing extended ASCII characters into a file in japanese machines

Suren BabuM
Greenhorn

Joined: Jun 19, 2002
Posts: 1
Take for eg., � is a registered sign (falls 174 entry in ASCII table.)
Requirement: To Read this character from database and write into file.
This character is getting returned from database properly. Once i write to file using the following code and opening the file in notepad it is showing as ?. I tried opening in binary mode to check the Hex. value and it is 63 (which is ?) instead of 174 (which is �)
result holds the information fetched from database.
BufferedWriter writer1 = new BufferedWriter ( new FileWriter("FromDatabase_native_CharacterIO.txt") ) ;
writer1.write ( result ) ;
writer1.flush() ;
writer1.close() ;
The following code works fine...
FileOutputStream fos = new FileOutputStream( "FromDatabase_unicode.txt" );
OutputStreamWriter osw = new OutputStreamWriter( fos, "Unicode" );
System.out.println("Encoding: "+ osw.getEncoding()) ;
BufferedWriter bw = new BufferedWriter( osw );
bw.write ( result ) ;
bw.flush() ;
bw.close() ;
I don't want to use encoding to mandate 'Unicode', as i have other problems with that.
Any help is highly appreciated as it is sitting in my head for quite some time troubling a lot.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Problem in writing extended ASCII characters into a file in japanese machines
 
jQuery in Action, 3rd edition