View Single Post
  #6 (permalink)  
Old 09-22-2008, 08:12 PM
Norm's Avatar
Norm Norm is offline
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
Norm is on a distinguished road
The 3F is a ?. Different encodings use that when they do NOT have a valid char to use.
Here's a quick demo program that shows how different encodings generate different results:
Code:
// Writing chars > ASCII or ??? import java.io.*; public class Test8 { public static void main(String[] args) { String data =new String("\u00a7\u0080"); // \u0080 written to file as 3F (?) with encoding CP437 // \u0080 written to file as 3F (?) with encoding CP1254 // \u0080 written to file as 80 with encoding 8859_1 System.out.println("data=" + data); //data=§? String[] codePages = {// "8859_1", "CP1254", //NCR added these "CP437", "CP737", "CP775", "CP850", "CP852", "CP855", "CP857", "CP860", "CP861", "CP862", "CP863", "CP864", "CP865", "CP866", "CP869", "CP874", "CP856", "CP858", "CP868", "CP870" }; try { FileOutputStream fos = new FileOutputStream("Text8Output.txt"); // write to file BufferedWriter wr1 = new BufferedWriter( new OutputStreamWriter(fos, codePages[0])); //java.io.UnsupportedEncodingException: Cp437 with 1.4.2 OK with 1.6.0 wr1.write(data); wr1.flush(); wr1.close(); }catch(Exception x) { x.printStackTrace(); } } // end main() } // end class
Reply With Quote