FileDocCategorySizeDatePackage
UnicodeBMPTable.javaAPI DocExample1254Wed Feb 15 04:53:54 GMT 2006None

UnicodeBMPTable

public class UnicodeBMPTable extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

    // Use platform default with a fallback to Latin-1 if necessary
    String encoding = System.getProperty("file.encoding", "ISO-8859-1");
    String lineSeparator = System.getProperty("line.separator", "\r\n");
    
    OutputStream target = System.out;
    if (args.length > 0) target = new FileOutputStream(args[0]);
    if (args.length > 1) encoding = args[1];
    
    OutputStreamWriter out = null;
    try {
      out = new OutputStreamWriter(target, encoding); 
    }
    catch (UnsupportedEncodingException ex) {
      // use platform default encoding
      out = new OutputStreamWriter(target);
    }
    
    try {
      for (int i = Character.MIN_VALUE; i <= Character.MAX_VALUE; i++) {
        // Skip undefined code points; these are not characters
        if (!Character.isDefined(i)) continue;
        
        char c = (char) i;
        // Surrogates are not full characters so skip them;
        // this requires Java 5
        if (Character.isHighSurrogate(c) || Character.isLowSurrogate(c)) continue;
        
        out.write(i + ":\t" + c + lineSeparator);
      }
    }
    finally {
      out.close();
    }