• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 don't like that guy. The tiny ad agrees with me.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic