make/jdk/src/classes/build/tools/charsetmapping/HKSCS.java
author pliden
Thu, 26 Sep 2019 13:56:58 +0200
changeset 58355 de246fd65587
parent 47216 71c04702a3d5
child 57136 c9bcd764f1f4
permissions -rw-r--r--
8231294: ZGC: vmTestbase/nsk/jvmti/ResourceExhausted/resexhausted002 fails Reviewed-by: shade, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5167
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 21805
diff changeset
     2
 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
5167
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
     4
 *
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5167
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
5167
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5167
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
5167
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    10
 *
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    15
 * accompanied this code).
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    16
 *
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5167
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5167
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5167
diff changeset
    23
 * questions.
5167
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    24
 */
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    25
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    26
package build.tools.charsetmapping;
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    27
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    28
import java.io.*;
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    29
import java.util.Arrays;
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    30
import java.util.ArrayList;
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    31
import java.util.Scanner;
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    32
import java.util.Formatter;
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    33
import java.util.regex.*;
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    34
import java.nio.charset.*;
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    35
import static build.tools.charsetmapping.Utils.*;
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    36
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    37
public class HKSCS {
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    38
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    39
    // HKSCS2001.map has the third column for "UnicodeAlternate", which
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    40
    // is for c->b non-roundtrip mapping.
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    41
    // For HKSCS2008, those non-roundtrip mappings are in .nr file
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    42
    private static Pattern hkscs =
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    43
        Pattern.compile("(?:0x)?+(\\p{XDigit}++)\\s++(?:0x|U\\+)?+(\\p{XDigit}++)?\\s*+(?:0x|U\\+)?(\\p{XDigit}++)?\\s*+.*");
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    44
29119
f680ba340556 8073893: Enable charsets build system to configure euc_tw into java.base module/sun.nio.cs
sherman
parents: 28969
diff changeset
    45
    static void genClass2008(String srcDir, String dstDir, String pkgName, File copyright)
28969
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 23010
diff changeset
    46
        throws Exception
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 23010
diff changeset
    47
    {
5167
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    48
        // hkscs2008
28969
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 23010
diff changeset
    49
        genClass0(new FileInputStream(new File(srcDir, "HKSCS2008.map")),
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 23010
diff changeset
    50
                  new FileInputStream(new File(srcDir, "HKSCS2008.c2b")),
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 23010
diff changeset
    51
                  new PrintStream(new File(dstDir, "HKSCSMapping.java"),
5167
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    52
                                  "ISO-8859-1"),
28969
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 23010
diff changeset
    53
                  pkgName,
5167
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    54
                  "HKSCSMapping",
28969
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 23010
diff changeset
    55
                  true,
29119
f680ba340556 8073893: Enable charsets build system to configure euc_tw into java.base module/sun.nio.cs
sherman
parents: 28969
diff changeset
    56
                  getCopyright(copyright));
f680ba340556 8073893: Enable charsets build system to configure euc_tw into java.base module/sun.nio.cs
sherman
parents: 28969
diff changeset
    57
28969
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 23010
diff changeset
    58
    }
5167
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    59
29119
f680ba340556 8073893: Enable charsets build system to configure euc_tw into java.base module/sun.nio.cs
sherman
parents: 28969
diff changeset
    60
    static void genClassXP(String srcDir, String dstDir, String pkgName, File copyright)
28969
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 23010
diff changeset
    61
        throws Exception
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 23010
diff changeset
    62
    {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 23010
diff changeset
    63
        genClass0(new FileInputStream(new File(srcDir, "HKSCS_XP.map")),
5167
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    64
                  null,
28969
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 23010
diff changeset
    65
                  new PrintStream(new File(dstDir, "HKSCS_XPMapping.java"),
5167
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    66
                                  "ISO-8859-1"),
28969
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 23010
diff changeset
    67
                  pkgName,
5167
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    68
                  "HKSCS_XPMapping",
28969
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 23010
diff changeset
    69
                  false,
29119
f680ba340556 8073893: Enable charsets build system to configure euc_tw into java.base module/sun.nio.cs
sherman
parents: 28969
diff changeset
    70
                  getCopyright(copyright));
28969
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 23010
diff changeset
    71
    }
5167
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    72
28969
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 23010
diff changeset
    73
    static void genClass2001(String args[]) throws Exception {
5167
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    74
        // hkscs2001
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    75
        genClass0(new FileInputStream(new File(args[0], "HKSCS2001.map")),
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    76
                  new FileInputStream(new File(args[0], "HKSCS2001.c2b")),
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    77
                  new PrintStream(new File(args[1], "HKSCS2001Mapping.java"),
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    78
                                  "ISO-8859-1"),
28969
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 23010
diff changeset
    79
                  "sun.nio.cs.ext",
5167
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    80
                  "HKSCS2001Mapping",
28969
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 23010
diff changeset
    81
                  false,
5167
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    82
                  getCopyright(new File(args[3])));
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    83
    }
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    84
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    85
    static void genClass0(InputStream isB2C,
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    86
                          InputStream isC2B,
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    87
                          PrintStream ps,
28969
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 23010
diff changeset
    88
                          String pkgName,
5167
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    89
                          String clzName,
28969
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 23010
diff changeset
    90
                          boolean isPublic,
5167
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    91
                          String copyright)
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    92
        throws Exception
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    93
    {
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    94
        // ranges of byte1 and byte2, something should come from a "config" file
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    95
        int b1Min = 0x87;
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    96
        int b1Max = 0xfe;
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    97
        int b2Min = 0x40;
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    98
        int b2Max = 0xfe;
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
    99
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   100
        try {
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   101
            char[] bmp = new char[0x10000];
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   102
            char[] supp = new char[0x10000];
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   103
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   104
            boolean[] b2cBmp = new boolean[0x100];
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   105
            boolean[] b2cSupp = new boolean[0x100];
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   106
            // pua should be in range of e000-f8ff. Expand
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   107
            // it to 0xf93b becase the hkscs2001.c2b has
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   108
            // the f920-f93b filled
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   109
            //char[] pua = new char[0xF8FF - 0xE000 + 1];
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   110
            char[] pua = new char[0xF93b - 0xE000 + 1];
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   111
            boolean hasSupp = false;
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   112
            boolean hasPua = false;
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   113
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   114
            Arrays.fill(bmp, UNMAPPABLE_DECODING);
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   115
            Arrays.fill(supp, UNMAPPABLE_DECODING);
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   116
            Arrays.fill(pua, UNMAPPABLE_DECODING);
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   117
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   118
            Parser p = new Parser(isB2C, hkscs);
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   119
            Entry  e = null;
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   120
            while ((e = p.next()) != null) {
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   121
                if (e.cp >= 0x10000) {
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   122
                    supp[e.bs] = (char)e.cp;
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   123
                    b2cSupp[e.bs>>8] = true;
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   124
                    hasSupp = true;
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   125
                } else {
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   126
                    bmp[e.bs] = (char)e.cp;
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   127
                    b2cBmp[e.bs>>8] = true;
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   128
                }
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   129
                if (e.cp2 != 0 && e.cp2 >= 0xe000 && e.cp2 <= 0xf8ff) {
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   130
                    hasPua = true;
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   131
                    pua[e.cp2 - 0xE000] = (char)e.bs;
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   132
                }
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   133
            }
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   134
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   135
            if (isC2B != null) {
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   136
                p = new Parser(isC2B, hkscs);
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   137
                e = null;
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   138
                while ((e = p.next()) != null) {
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   139
                    pua[e.cp - 0xE000] = (char)e.bs;
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   140
                }
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   141
                hasPua = true;
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   142
            }
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   143
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   144
            StringBuilder sb = new StringBuilder();
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   145
            Output out = new Output(new Formatter(sb));
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   146
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   147
            out.format(copyright);
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   148
            out.format("%n// -- This file was mechanically generated: Do not edit! -- //%n");
28969
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 23010
diff changeset
   149
            out.format("package %s;%n%n", pkgName);
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 23010
diff changeset
   150
            out.format("%sclass %s {%n%n", isPublic ? "public " : "", clzName);
5167
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   151
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   152
            /* hardcoded in sun.nio.cs.ext.HKSCS.java
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   153
            out.format("    final static int b1Min = 0x%x;%n", b1Min);
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   154
            out.format("    final static int b1Max = 0x%x;%n", b1Max);
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   155
            out.format("    final static int b2Min = 0x%x;%n", b2Min);
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   156
            out.format("    final static int b2Max = 0x%x;%n", b2Max);
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   157
            */
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   158
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   159
            // bmp tables
28969
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 23010
diff changeset
   160
            out.format("%n    %sstatic final String[] b2cBmpStr = new String[] {%n",
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 23010
diff changeset
   161
                       isPublic ? "public " : "");
5167
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   162
            for (int i = 0; i < 0x100; i++) {
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   163
                if (b2cBmp[i])
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   164
                    out.format(bmp, i, b2Min, b2Max, ",");
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   165
                else
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   166
                    out.format("        null,%n");  //unmappable segments
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   167
            }
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   168
            out.format("        };%n");
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   169
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   170
            // supp tables
28969
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 23010
diff changeset
   171
            out.format("%n    %sstatic final String[] b2cSuppStr =",
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 23010
diff changeset
   172
                       isPublic ? "public " : "");
5167
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   173
            if (hasSupp) {
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   174
                out.format(" new String[] {%n");
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   175
                for (int i = 0; i < 0x100; i++) {
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   176
                    if (b2cSupp[i])
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   177
                        out.format(supp, i, b2Min, b2Max, ",");
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   178
                    else
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   179
                        out.format("        null,%n");  //unmappable segments
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   180
                }
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   181
                out.format("        };%n");
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   182
            } else {
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   183
                out.format(" null;%n");
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   184
            }
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   185
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   186
            // private area tables
28969
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 23010
diff changeset
   187
            out.format("%n    %sfinal static String pua =",
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 23010
diff changeset
   188
                       isPublic ? "public " : "");
5167
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   189
            if (hasPua) {
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   190
                out.format("%n");
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   191
                out.format(pua, 0, pua.length, ";");
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   192
            } else {
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   193
                out.format(" null;%n");
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   194
            }
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   195
            out.format("%n");
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   196
            out.format("}");
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   197
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   198
            out.close();
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   199
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   200
            ps.println(sb.toString());
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   201
            ps.close();
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   202
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   203
        } catch (Exception x) {
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   204
            x.printStackTrace();
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   205
        }
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   206
    }
dbd299f8fdae 6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff changeset
   207
}