make/tools/src/build/tools/charsetmapping/GenerateSBCS.java

Print this page




  38 
  39     public static void genSBCS(String args[]) throws Exception {
  40 
  41         Scanner s = new Scanner(new File(args[0], args[2]));
  42         while (s.hasNextLine()) {
  43             String line = s.nextLine();
  44             if (line.startsWith("#") || line.length() == 0)
  45                 continue;
  46             String[] fields = line.split("\\s+");
  47             if (fields.length < 5) {
  48                 System.err.println("Misconfiged sbcs line <" + line + ">?");
  49                 continue;
  50             }
  51             String clzName = fields[0];
  52             String csName  = fields[1];
  53             String hisName = fields[2];
  54             boolean isASCII = Boolean.valueOf(fields[3]);
  55             String pkgName  = fields[4];
  56             System.out.printf("%s,%s,%s,%b,%s%n", clzName, csName, hisName, isASCII, pkgName);
  57 
  58             genClass(args[0], args[1], "SingleByte-X.java",
  59                      clzName, csName, hisName, pkgName, isASCII);
  60         }
  61     }
  62 
  63     private static void toString(char[] sb, int off, int end,
  64                                  Formatter out, String closure,
  65                                  boolean comment) {
  66         while (off < end) {
  67             out.format("        \"");
  68             for (int j = 0; j < 8; j++) {
  69                 if (off == end)
  70                     break;
  71                 char c = sb[off++];
  72                 switch (c) {
  73                 case '\b':
  74                     out.format("\\b"); break;
  75                 case '\t':
  76                     out.format("\\t"); break;
  77                 case '\n':
  78                     out.format("\\n"); break;




  38 
  39     public static void genSBCS(String args[]) throws Exception {
  40 
  41         Scanner s = new Scanner(new File(args[0], args[2]));
  42         while (s.hasNextLine()) {
  43             String line = s.nextLine();
  44             if (line.startsWith("#") || line.length() == 0)
  45                 continue;
  46             String[] fields = line.split("\\s+");
  47             if (fields.length < 5) {
  48                 System.err.println("Misconfiged sbcs line <" + line + ">?");
  49                 continue;
  50             }
  51             String clzName = fields[0];
  52             String csName  = fields[1];
  53             String hisName = fields[2];
  54             boolean isASCII = Boolean.valueOf(fields[3]);
  55             String pkgName  = fields[4];
  56             System.out.printf("%s,%s,%s,%b,%s%n", clzName, csName, hisName, isASCII, pkgName);
  57 
  58             genClass(args[0], args[1], "SingleByte-X.java.template",
  59                      clzName, csName, hisName, pkgName, isASCII);
  60         }
  61     }
  62 
  63     private static void toString(char[] sb, int off, int end,
  64                                  Formatter out, String closure,
  65                                  boolean comment) {
  66         while (off < end) {
  67             out.format("        \"");
  68             for (int j = 0; j < 8; j++) {
  69                 if (off == end)
  70                     break;
  71                 char c = sb[off++];
  72                 switch (c) {
  73                 case '\b':
  74                     out.format("\\b"); break;
  75                 case '\t':
  76                     out.format("\\t"); break;
  77                 case '\n':
  78                     out.format("\\n"); break;