2001-08-31 00:30:17 +00:00
|
|
|
/**
|
|
|
|
*******************************************************************************
|
|
|
|
* Copyright (C) 1996-2001, International Business Machines Corporation and *
|
|
|
|
* others. All Rights Reserved. *
|
|
|
|
*******************************************************************************
|
|
|
|
*
|
|
|
|
* $Source: /xsrl/Nsvn/icu/unicodetools/com/ibm/text/UCD/VerifyUCD.java,v $
|
2003-07-21 15:50:07 +00:00
|
|
|
* $Date: 2003/07/21 15:50:05 $
|
|
|
|
* $Revision: 1.22 $
|
2001-08-31 00:30:17 +00:00
|
|
|
*
|
|
|
|
*******************************************************************************
|
|
|
|
*/
|
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
package com.ibm.text.UCD;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
|
|
//import com.ibm.text.unicode.UInfo;
|
|
|
|
import java.util.*;
|
|
|
|
import java.io.*;
|
2002-03-15 00:34:46 +00:00
|
|
|
//import java.text.Un;
|
2002-03-15 01:57:01 +00:00
|
|
|
import com.ibm.icu.text.CanonicalIterator;
|
|
|
|
import com.ibm.icu.text.UnicodeSet;
|
2002-06-22 01:21:11 +00:00
|
|
|
import com.ibm.icu.text.UnicodeSetIterator;
|
|
|
|
|
2002-03-15 01:57:01 +00:00
|
|
|
import com.ibm.icu.text.UTF16;
|
2001-08-30 20:50:18 +00:00
|
|
|
import com.ibm.text.utility.*;
|
2002-04-23 01:59:16 +00:00
|
|
|
import java.text.NumberFormat;
|
2001-08-30 20:50:18 +00:00
|
|
|
|
|
|
|
public class VerifyUCD implements UCD_Types {
|
2002-06-22 01:21:11 +00:00
|
|
|
static final boolean DEBUG = false;
|
2002-06-15 02:47:14 +00:00
|
|
|
|
2002-08-09 23:56:24 +00:00
|
|
|
static void checkDecompFolding() {
|
|
|
|
Default.setUCD();
|
|
|
|
UnicodeSet sum = new UnicodeSet();
|
|
|
|
for (int cp = 0; cp <= 0x10FFFF; ++cp) {
|
|
|
|
Utility.dot(cp);
|
|
|
|
if (!Default.ucd.isAllocated(cp)) continue;
|
|
|
|
byte cat = Default.ucd.getCategory(cp);
|
|
|
|
if (cat == UNASSIGNED || cat == PRIVATE_USE) continue;
|
|
|
|
String decomp = Default.nfd.normalize(cp);
|
|
|
|
String foldDecomp = Default.ucd.getCase(decomp, FULL, FOLD);
|
|
|
|
int d0 = Default.ucd.getCombiningClass(decomp.charAt(0));
|
|
|
|
int dL = Default.ucd.getCombiningClass(decomp.charAt(decomp.length()-1));
|
|
|
|
int f0 = Default.ucd.getCombiningClass(foldDecomp.charAt(0));
|
|
|
|
int fL = Default.ucd.getCombiningClass(foldDecomp.charAt(decomp.length()-1));
|
|
|
|
if (d0 != f0 || dL != fL) {
|
|
|
|
Utility.fixDot();
|
|
|
|
System.out.println();
|
|
|
|
System.out.println("Exception: " + Default.ucd.getCodeAndName(cp));
|
|
|
|
System.out.println("Decomp: " + Default.ucd.getCodeAndName(decomp));
|
|
|
|
System.out.println("FoldedDecomp: " + Default.ucd.getCodeAndName(foldDecomp));
|
|
|
|
System.out.println("d0: " + d0 + ", "
|
|
|
|
+ "dL: " + dL + ", "
|
|
|
|
+ "f0: " + f0 + ", "
|
|
|
|
+ "fL: " + fL
|
|
|
|
);
|
|
|
|
sum.add(cp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
System.out.println("Set: " + sum.toPattern(true));
|
|
|
|
}
|
|
|
|
|
2002-06-15 02:47:14 +00:00
|
|
|
static void oneTime() {
|
|
|
|
Default.setUCD();
|
|
|
|
int[] testSet = {0x10000, 'a', 0xE0000, '\u0221'}; // 10000
|
|
|
|
for (int i = 0; i < testSet.length; ++i) {
|
|
|
|
int item = testSet[i];
|
|
|
|
System.out.println(Default.ucd.getCode(item));
|
|
|
|
|
|
|
|
boolean ass = Default.ucd.isAssigned(item);
|
|
|
|
System.out.println(ass ? " assigned" : " unassigned");
|
|
|
|
ass = Default.ucd.isAllocated(item);
|
|
|
|
System.out.println(ass ? " allocated" : " unallocated");
|
|
|
|
|
|
|
|
String name = Default.ucd.getName(item, SHORT);
|
|
|
|
System.out.println(" " + name);
|
|
|
|
name = Default.ucd.getName(item);
|
|
|
|
System.out.println(" " + name);
|
|
|
|
|
|
|
|
System.out.println();
|
|
|
|
}
|
|
|
|
}
|
2002-04-23 01:59:16 +00:00
|
|
|
|
|
|
|
static final byte NC = UNUSED_CATEGORY;
|
|
|
|
|
|
|
|
static final NumberFormat format = NumberFormat.getInstance();
|
|
|
|
static {
|
|
|
|
format.setMinimumFractionDigits(0);
|
|
|
|
format.setGroupingUsed(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static abstract class SimpleProp {
|
|
|
|
abstract String getTitle();
|
|
|
|
abstract byte getUnallocatedProp();
|
|
|
|
abstract byte getProp(int cp);
|
|
|
|
abstract String getName(byte prop);
|
|
|
|
abstract String getCode(byte prop);
|
|
|
|
|
|
|
|
byte[] subtotalBreaks = null;
|
|
|
|
|
|
|
|
byte[] cumulativeTotalBreaks = null;
|
|
|
|
|
|
|
|
byte[] permute = null;
|
|
|
|
|
|
|
|
byte getPermutation(byte prop) {
|
|
|
|
if (permute == null) return prop;
|
|
|
|
if (prop >= permute.length) return prop;
|
|
|
|
return permute[prop];
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean doTotal(byte prop, boolean sub) {
|
|
|
|
byte[] myBreak = sub ? subtotalBreaks : cumulativeTotalBreaks;
|
|
|
|
if (myBreak == null) return false;
|
|
|
|
for (int k = 0; k < myBreak.length; ++k) {
|
|
|
|
if (myBreak[k] == prop) return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static class CatProp extends SimpleProp {
|
|
|
|
String getTitle() {
|
|
|
|
return "General Category";
|
|
|
|
}
|
|
|
|
byte getUnallocatedProp() {
|
|
|
|
return Cn;
|
|
|
|
}
|
|
|
|
|
|
|
|
byte getProp(int cp) {
|
|
|
|
byte cat = Default.ucd.getCategory(cp);
|
|
|
|
if (cat == Cn && Default.ucd.getBinaryProperty(cp, Noncharacter_Code_Point)) {
|
|
|
|
return NC;
|
|
|
|
}
|
|
|
|
return cat;
|
|
|
|
}
|
|
|
|
String getCode(byte prop) {
|
|
|
|
if (prop >= LIMIT_CATEGORY) return "???" + prop;
|
|
|
|
if (prop == NC) {
|
|
|
|
return "NC";
|
|
|
|
}
|
|
|
|
return Default.ucd.getCategoryID_fromIndex(prop);
|
|
|
|
}
|
|
|
|
String getName(byte prop) {
|
|
|
|
if (prop >= LIMIT_CATEGORY) return "???" + prop;
|
|
|
|
if (prop == NC) {
|
|
|
|
return "Noncharacter";
|
|
|
|
}
|
|
|
|
String name = Default.ucd.getCategoryID_fromIndex(prop, LONG);
|
|
|
|
if (prop == Cn) name += " - NC";
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
permute = new byte[] {
|
|
|
|
Lu, Ll, Lt, Lo, Lm,
|
|
|
|
Mn, Me, Mc,
|
|
|
|
Nd, Nl, No,
|
|
|
|
Pd, Pc, Ps, Pi, Pe, Pf, Po,
|
|
|
|
Sc, Sm, Sk, So,
|
|
|
|
Zs, Zl, Zp,
|
|
|
|
Cc, Cf, Co, Cs, NC, Cn};
|
|
|
|
|
|
|
|
subtotalBreaks = new byte[] {Lm, Mc, No, Po, So, Zp, Cs, Cn};
|
|
|
|
|
|
|
|
cumulativeTotalBreaks = new byte[] {Cf};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static class ScriptProp extends SimpleProp {
|
|
|
|
String getTitle() {
|
|
|
|
return "Script";
|
|
|
|
}
|
|
|
|
byte getUnallocatedProp() {
|
|
|
|
return COMMON_SCRIPT;
|
|
|
|
}
|
|
|
|
|
|
|
|
byte getProp(int cp) {
|
|
|
|
return Default.ucd.getScript(cp);
|
|
|
|
}
|
|
|
|
String getCode(byte prop) {
|
|
|
|
if (prop >= LIMIT_SCRIPT) return "???" + prop;
|
|
|
|
return Default.ucd.getScriptID_fromIndex(prop, SHORT);
|
|
|
|
}
|
|
|
|
String getName(byte prop) {
|
|
|
|
if (prop >= LIMIT_SCRIPT) return "???" + prop;
|
|
|
|
return Default.ucd.getScriptID_fromIndex(prop, LONG);
|
|
|
|
}
|
|
|
|
byte getPermutation(byte prop) {
|
|
|
|
if (prop == LIMIT_SCRIPT-1) return COMMON_SCRIPT;
|
|
|
|
if (prop == LIMIT_SCRIPT-2) return INHERITED_SCRIPT;
|
|
|
|
if (prop >= LIMIT_SCRIPT) return prop;
|
|
|
|
if (prop >= INHERITED_SCRIPT-1) return (byte)(prop+2);
|
|
|
|
return (byte)(prop+1);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
cumulativeTotalBreaks = new byte[] {TAGBANWA_SCRIPT};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static SimpleProp CAT_PROP = new CatProp();
|
|
|
|
static SimpleProp SCRIPT_PROP = new ScriptProp();
|
|
|
|
|
|
|
|
public static void statistics() throws IOException {
|
|
|
|
statistics(CAT_PROP);
|
|
|
|
System.out.println("<p>");
|
|
|
|
statistics(SCRIPT_PROP);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void statistics(SimpleProp prop) throws IOException {
|
|
|
|
int[][] count = new int[100][5];
|
|
|
|
int[][] sample = new int[100][5];
|
|
|
|
int[] subtotalCount = new int[5];
|
|
|
|
int[] totalCount = new int[5];
|
|
|
|
|
|
|
|
|
|
|
|
Default.setUCD();
|
|
|
|
byte cat;
|
|
|
|
for (int cp = 0; cp <= 0x10FFFF; ++cp) {
|
|
|
|
Utility.dot(cp);
|
|
|
|
if (!Default.ucd.isAllocated(cp)) {
|
|
|
|
cat = prop.getUnallocatedProp();
|
|
|
|
setSample(count[cat], sample[cat], 0, cp);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
cat = prop.getProp(cp);
|
|
|
|
setSample(count[cat], sample[cat], 0, cp);
|
|
|
|
|
|
|
|
if (checkNormalizer(Default.nfd, cp)) {
|
|
|
|
setSample(count[cat], sample[cat], NFD+1, cp);
|
|
|
|
}
|
|
|
|
if (checkNormalizer(Default.nfc, cp)) {
|
|
|
|
setSample(count[cat], sample[cat], NFC+1, cp);
|
|
|
|
}
|
|
|
|
if (checkNormalizer(Default.nfkd, cp)) {
|
|
|
|
setSample(count[cat], sample[cat], NFKD+1, cp);
|
|
|
|
}
|
|
|
|
if (checkNormalizer(Default.nfkc, cp)) {
|
|
|
|
setSample(count[cat], sample[cat], NFKC+1, cp);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Utility.fixDot();
|
|
|
|
|
|
|
|
System.out.println("<table border='1' cellspacing='0' cellpadding='4'>");
|
|
|
|
System.out.print("<tr><th class='tt' colspan='2'>" + prop.getTitle() + "</th><th class='tn' colspan='2'>Count");
|
|
|
|
for (byte j = 0; j < 4; ++j) {
|
|
|
|
System.out.println("</th><th class='tn' colspan='2'>" + UCD_Names.NF_NAME[j]);
|
|
|
|
}
|
|
|
|
System.out.println("</th></tr>");
|
|
|
|
|
|
|
|
for (byte ii = 0; ii < count.length; ++ii) {
|
|
|
|
byte i = prop.getPermutation(ii);
|
|
|
|
// System.out.println(prop.getCode(ii) + ", " + ii + " => " + prop.getCode(i) + ", " + i);
|
|
|
|
if (count[i][0] == 0) continue;
|
|
|
|
|
|
|
|
String code = prop.getCode(i);
|
|
|
|
String name = prop.getName(i);
|
|
|
|
|
|
|
|
System.out.println(" <tr><th class='t'>" + code + "</th><th class='t'>" + name + "</th>");
|
|
|
|
for (byte j = 0; j < 5; ++j) {
|
|
|
|
if (count[i][j] == 0) System.out.println("<td colspan='2'> </td>");
|
|
|
|
else {
|
|
|
|
System.out.println(" <td class='n'><b>" + format.format(count[i][j]) + "</b></td>");
|
|
|
|
System.out.println(" <td class='s'><div title='" +
|
|
|
|
Default.ucd.getCodeAndName(sample[i][j]) + "'>" + quote(sample[i][j]) + "</div></td>");
|
|
|
|
}
|
|
|
|
subtotalCount[j] += count[i][j];
|
|
|
|
totalCount[j] += count[i][j];
|
|
|
|
}
|
|
|
|
System.out.println(" </tr>");
|
|
|
|
if (prop.doTotal(i, true)) printTotals("Subtotal", subtotalCount, true);
|
|
|
|
if (prop.doTotal(i, false)) printTotals("Cumulative Total", totalCount, false);
|
|
|
|
}
|
|
|
|
printTotals("Total", totalCount, false);
|
|
|
|
System.out.println("</table>");
|
|
|
|
}
|
|
|
|
|
|
|
|
static public String quote(int cp) {
|
|
|
|
byte cat2 = Default.ucd.getCategory(cp);
|
|
|
|
if (cat2 == Zs || cat2 == Zp || cat2 == Zl) return " ";
|
|
|
|
if (cat2 == Cc || cat2 == Cs) return "??";
|
|
|
|
if (cat2 == Mn || cat2 == Me || cat2 == Mc) return "◌&#" + cp + ";";
|
|
|
|
return "&#" + cp + ";";
|
|
|
|
}
|
|
|
|
|
|
|
|
static public void setSample(int[] count, int[] array, int index, int cp) {
|
|
|
|
count[index]++;
|
|
|
|
int value = array[index];
|
|
|
|
if (value == 0) {
|
|
|
|
array[index] = cp;
|
|
|
|
} else if (Default.ucd.isAllocated(cp)) {
|
|
|
|
int ncount1 = getNFCount(value, index);
|
|
|
|
int ncount2 = getNFCount(cp, index);
|
|
|
|
if (ncount1 != ncount2) {
|
|
|
|
if (ncount1 > ncount2) array[index] = cp;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
byte cat1 = CAT_PROP.getPermutation(CAT_PROP.getProp(value));
|
|
|
|
byte cat2 = CAT_PROP.getPermutation(CAT_PROP.getProp(cp));
|
|
|
|
if (cat1 > cat2) array[index] = cp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int getNFCount(int cp, int index) {
|
|
|
|
int count = 0;
|
|
|
|
boolean nfc1 = checkNormalizer(Default.nfc, cp);
|
|
|
|
boolean nfd1 = checkNormalizer(Default.nfd, cp);
|
|
|
|
boolean nfkc1 = checkNormalizer(Default.nfkc, cp);
|
|
|
|
boolean nfkd1 = checkNormalizer(Default.nfkd, cp);
|
|
|
|
if (nfc1) count += 1;
|
|
|
|
if (nfd1) count += 2;
|
|
|
|
if (nfkc1) count += 4;
|
|
|
|
if (nfkd1) count += 8;
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void printTotals(String title, int[] subtotalCount, boolean zeroit) {
|
|
|
|
System.out.println(" <tr><th class='tt' colspan='2'>" + title + "</th>");
|
|
|
|
for (byte j = 0; j < subtotalCount.length; ++j) {
|
|
|
|
System.out.println(" <td class='tn' colspan='2'>"
|
|
|
|
+ (subtotalCount[j] == 0 ? "" : format.format(subtotalCount[j])) + "</td>");
|
|
|
|
if (zeroit) subtotalCount[j] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean checkNormalizer(Normalizer x, int cp) {
|
2002-05-31 01:41:04 +00:00
|
|
|
boolean result = !x.isNormalized(cp);
|
2002-04-23 01:59:16 +00:00
|
|
|
if (false) {
|
|
|
|
String s = x.normalize(cp);
|
|
|
|
boolean sResult = !s.equals(UTF16.valueOf(cp));
|
|
|
|
if (result != sResult) {
|
|
|
|
System.out.println("Failure with " + x + " at " + Default.ucd.getCodeAndName(cp));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2001-12-13 23:36:29 +00:00
|
|
|
|
2002-05-29 02:01:00 +00:00
|
|
|
public static void checkBIDI() {
|
|
|
|
Default.setUCD();
|
|
|
|
|
|
|
|
for (int cp = 0; cp <= 0x10FFFF; ++cp) {
|
|
|
|
Utility.dot(cp);
|
|
|
|
if (!Default.ucd.isAllocated(cp)) continue;
|
|
|
|
|
2002-05-31 01:41:04 +00:00
|
|
|
if (Default.nfd.isNormalized(cp)) continue;
|
2002-05-29 02:01:00 +00:00
|
|
|
|
|
|
|
String decomp = Default.nfd.normalize(cp);
|
|
|
|
String comp = Default.nfc.normalize(cp);
|
|
|
|
String source = UTF16.valueOf(cp);
|
|
|
|
|
|
|
|
String bidiDecomp = getBidi(decomp, true);
|
|
|
|
String bidiComp = getBidi(comp, true);
|
|
|
|
String bidiSource = getBidi(source, true);
|
|
|
|
|
|
|
|
if (!bidiDecomp.equals(bidiSource) || !bidiComp.equals(bidiSource)) {
|
|
|
|
Utility.fixDot();
|
|
|
|
System.out.println(Default.ucd.getCodeAndName(cp) + ": " + getBidi(source, false));
|
|
|
|
System.out.println("\tNFC: " + Default.ucd.getCodeAndName(comp) + ": " + getBidi(comp, false));
|
|
|
|
System.out.println("\tNFD: " + Default.ucd.getCodeAndName(decomp) + ": " + getBidi(decomp, false));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static String getBidi(String s, boolean compact) {
|
|
|
|
String result = "";
|
|
|
|
byte lastBidi = -1;
|
|
|
|
int cp;
|
|
|
|
for (int i = 0; i < s.length(); i += UTF16.getCharCount(cp)) {
|
|
|
|
cp = UTF16.charAt(s, i);
|
|
|
|
byte bidi = Default.ucd.getBidiClass(cp);
|
|
|
|
if (compact) {
|
|
|
|
if (bidi == BIDI_NSM) {
|
|
|
|
if (lastBidi != -1) bidi = lastBidi;
|
|
|
|
}
|
|
|
|
if (bidi == lastBidi && bidi != BIDI_ES && bidi != BIDI_CS) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result += Default.ucd.getCase(
|
|
|
|
Default.ucd.getBidiClassID_fromIndex(bidi, SHORT), FULL, TITLE);
|
|
|
|
lastBidi = bidi;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2001-12-13 23:36:29 +00:00
|
|
|
public static void verify() throws IOException {
|
2002-04-23 01:59:16 +00:00
|
|
|
Default.setUCD();
|
2001-12-13 23:36:29 +00:00
|
|
|
|
|
|
|
checkIdentical("ea=h", "dt=nar");
|
|
|
|
checkIdentical("ea=f", "dt=wide");
|
|
|
|
checkIdentical("gc=ps", "lb=op");
|
|
|
|
checkIdentical("lb=sg", "gc=cs");
|
|
|
|
|
|
|
|
/*
|
|
|
|
For LB we now have:
|
|
|
|
|
|
|
|
GC:Ps == LB:OP
|
|
|
|
GC:Nd && !(EA:F)
|
|
|
|
|
|
|
|
Try these on for size, and report any discrepancies
|
|
|
|
|
|
|
|
>GC:L& && EA:W -> LB:ID
|
|
|
|
>GC:L& && EA:A -> LB:AI
|
|
|
|
>GC:L& && EA:N -> LB:AL
|
|
|
|
>GC:L& && EA:Na -> LB:AL
|
|
|
|
|
|
|
|
plus
|
|
|
|
|
|
|
|
>LB:ID contains Ideo:T
|
|
|
|
|
|
|
|
Also, try these rules
|
|
|
|
|
|
|
|
GC:S# && EA:W -> LB:ID
|
|
|
|
GC:S# && EA:A -> LB:AI
|
|
|
|
GC:S# && EA:N -> LB:AL
|
|
|
|
GC:S# && EA:Na -> LB:AL
|
|
|
|
|
|
|
|
where S# is Sm | Sk | So
|
|
|
|
|
|
|
|
these will generate exceptions, but I need to see the list to them before I
|
|
|
|
can help you narrow these down.
|
|
|
|
|
|
|
|
>The trivial ones that I could glean from reading the TR are
|
|
|
|
>LB:SG == GC:Cs
|
|
|
|
>GC:Pi -> LB:QU
|
|
|
|
>GC:Pf -> LB:QU
|
|
|
|
>GC:Mc -> LB:CM
|
|
|
|
>GC:Me -> LB:CM
|
|
|
|
>GC:Mn -> LB:CM
|
|
|
|
>GC:Pe -> LB:CL
|
|
|
|
*/
|
2002-03-15 00:34:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static final void checkCase3 () {
|
2002-04-23 01:59:16 +00:00
|
|
|
Default.setUCD();
|
2002-03-15 00:34:46 +00:00
|
|
|
|
|
|
|
checkNF_AndCase("\u0130", true);
|
|
|
|
checkNF_AndCase("\u0131", true);
|
|
|
|
|
|
|
|
UnicodeProperty softdot = null;
|
|
|
|
CanonicalIterator cit = new CanonicalIterator("a");
|
|
|
|
UnicodeSet badChars = new UnicodeSet();
|
|
|
|
|
2001-12-13 23:36:29 +00:00
|
|
|
for (int cp = 0; cp <= 0x10FFFF; ++cp) {
|
|
|
|
Utility.dot(cp);
|
2002-04-23 01:59:16 +00:00
|
|
|
if (!Default.ucd.isAllocated(cp)) continue;
|
|
|
|
byte cat = Default.ucd.getCategory(cp);
|
2002-03-15 00:34:46 +00:00
|
|
|
// check if canonical equivalents are case-mapped to canonical equivalents
|
|
|
|
if (cat != PRIVATE_USE && cat != SURROGATE) {
|
|
|
|
String str = UTF16.valueOf(cp);
|
|
|
|
if (!checkNF_AndCase(str, false)) badChars.add(cp);
|
2002-04-23 01:59:16 +00:00
|
|
|
//if (Default.ucd.getScript(cp) != GREEK_SCRIPT) continue;
|
2002-03-15 00:34:46 +00:00
|
|
|
str += "\u0334";
|
|
|
|
try {
|
2002-04-23 01:59:16 +00:00
|
|
|
//System.out.println("Check " + Default.ucd.getCodeAndName(str));
|
2002-03-15 00:34:46 +00:00
|
|
|
cit.setSource(str);
|
|
|
|
while (true) {
|
|
|
|
String s = cit.next();
|
|
|
|
if (s == null) break;
|
|
|
|
if (s.equals(str)) continue; // don't check twice
|
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
//System.out.println(" Checking " + Default.ucd.getCodeAndName(s));
|
2002-03-15 00:34:46 +00:00
|
|
|
if (!checkNF_AndCase(s, false)) badChars.add(cp);
|
|
|
|
}
|
|
|
|
} catch (StringIndexOutOfBoundsException e) {
|
2002-04-23 01:59:16 +00:00
|
|
|
System.out.println("Problem with " + Default.ucd.getCodeAndName(str));
|
2002-03-15 00:34:46 +00:00
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
|
2001-12-13 23:36:29 +00:00
|
|
|
}
|
|
|
|
|
2002-03-15 00:34:46 +00:00
|
|
|
if (false) {
|
2002-04-23 01:59:16 +00:00
|
|
|
if (softdot == null) softdot = DerivedProperty.make(Type_i, Default.ucd);
|
|
|
|
if (Default.ucd.getBinaryProperty(cp, Soft_Dotted) !=
|
2002-03-15 00:34:46 +00:00
|
|
|
softdot.hasValue(cp)) {
|
2002-04-23 01:59:16 +00:00
|
|
|
System.out.println("FAIL: " + Default.ucd.getCodeAndName(cp));
|
|
|
|
System.out.println("Soft_Dotted='" + Default.ucd.getBinaryPropertiesID(cp, Soft_Dotted)
|
2002-03-15 00:34:46 +00:00
|
|
|
+ "', DerivedSD=" + softdot.getValue(cp) + "'");
|
|
|
|
}
|
2001-12-13 23:36:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2002-03-15 00:34:46 +00:00
|
|
|
System.out.println();
|
2002-04-23 01:59:16 +00:00
|
|
|
Utility.showSetNames("", badChars, false, Default.ucd);
|
2001-12-13 23:36:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void checkIdentical(String ubpName1, String ubpName2) {
|
2002-04-23 01:59:16 +00:00
|
|
|
UnicodeProperty prop1 = UnifiedBinaryProperty.make(ubpName1, Default.ucd);
|
2001-12-13 23:36:29 +00:00
|
|
|
UnicodeSet set1 = prop1.getSet();
|
2002-04-23 01:59:16 +00:00
|
|
|
UnicodeProperty prop2 = UnifiedBinaryProperty.make(ubpName2, Default.ucd);
|
2001-12-13 23:36:29 +00:00
|
|
|
UnicodeSet set2 = prop2.getSet();
|
|
|
|
UnicodeSet set1minus2 = new UnicodeSet(set1);
|
|
|
|
set1minus2.removeAll(set2);
|
|
|
|
UnicodeSet set2minus1 = new UnicodeSet(set2);
|
|
|
|
set2minus1.removeAll(set1);
|
|
|
|
|
|
|
|
if (set1minus2.isEmpty() && set2minus1.isEmpty()) {
|
|
|
|
System.out.println("PASS: " + prop1.getFullName(LONG) + " == " + prop2.getFullName(LONG));
|
|
|
|
System.out.println();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
System.out.println("FAIL: " + prop1.getFullName(LONG) + " != " + prop2.getFullName(LONG));
|
|
|
|
if (!set1minus2.isEmpty()) {
|
|
|
|
System.out.println(" In " + prop1.getFullName(LONG) + " but not " + prop2.getFullName(LONG));
|
2002-04-23 01:59:16 +00:00
|
|
|
Utility.showSetNames(" " + prop1.getFullName(SHORT) + ": ", set1minus2, false, Default.ucd);
|
2001-12-13 23:36:29 +00:00
|
|
|
}
|
|
|
|
if (!set2minus1.isEmpty()) {
|
|
|
|
System.out.println(" In " + prop2.getFullName(LONG) + " but not " + prop1.getFullName(LONG));
|
2002-04-23 01:59:16 +00:00
|
|
|
Utility.showSetNames(" " + prop2.getFullName(SHORT) + ": ", set2minus1, false, Default.ucd);
|
2001-12-13 23:36:29 +00:00
|
|
|
}
|
|
|
|
System.out.println();
|
|
|
|
}
|
|
|
|
|
2002-03-15 00:34:46 +00:00
|
|
|
static boolean checkNF_AndCase(String source, boolean both) {
|
|
|
|
boolean result = true;
|
2002-04-23 01:59:16 +00:00
|
|
|
String decomp = Default.nfd.normalize(source);
|
2002-03-15 00:34:46 +00:00
|
|
|
if (!decomp.equals(source)) {
|
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
result &= checkNFC("Lower", source, decomp, Default.ucd.getCase(source, FULL, LOWER), Default.ucd.getCase(decomp, FULL, LOWER));
|
|
|
|
result &= checkNFC("Upper", source, decomp, Default.ucd.getCase(source, FULL, UPPER), Default.ucd.getCase(decomp, FULL, UPPER));
|
|
|
|
result &= checkNFC("Title", source, decomp, Default.ucd.getCase(source, FULL, TITLE), Default.ucd.getCase(decomp, FULL, TITLE));
|
|
|
|
result &= checkNFC("Fold", source, decomp, Default.ucd.getCase(source, FULL, FOLD), Default.ucd.getCase(decomp, FULL, FOLD));
|
2002-03-15 00:34:46 +00:00
|
|
|
|
|
|
|
if (!both) return result;
|
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
result &= checkNFC("SLower", source, decomp, Default.ucd.getCase(source, SIMPLE, LOWER), Default.ucd.getCase(decomp, SIMPLE, LOWER));
|
|
|
|
result &= checkNFC("SUpper", source, decomp, Default.ucd.getCase(source, SIMPLE, UPPER), Default.ucd.getCase(decomp, SIMPLE, UPPER));
|
|
|
|
result &= checkNFC("STitle", source, decomp, Default.ucd.getCase(source, SIMPLE, TITLE), Default.ucd.getCase(decomp, SIMPLE, TITLE));
|
|
|
|
result &= checkNFC("SFold", source, decomp, Default.ucd.getCase(source, SIMPLE, TITLE), Default.ucd.getCase(decomp, SIMPLE, TITLE));
|
2001-12-13 23:36:29 +00:00
|
|
|
}
|
2002-03-15 00:34:46 +00:00
|
|
|
return result;
|
2001-12-13 23:36:29 +00:00
|
|
|
}
|
|
|
|
|
2002-03-15 00:34:46 +00:00
|
|
|
static final boolean SHOW_NFC_DIFFERENCE = false;
|
|
|
|
|
|
|
|
static boolean checkNFC(String label, String source, String decomp, String casedCp, String casedDecomp) {
|
2002-04-23 01:59:16 +00:00
|
|
|
if (!Default.nfd.normalize(casedCp).equals(Default.nfd.normalize(casedDecomp))) {
|
2002-03-15 00:34:46 +00:00
|
|
|
if (SHOW_NFC_DIFFERENCE) {
|
|
|
|
Utility.fixDot();
|
2002-04-23 01:59:16 +00:00
|
|
|
System.out.println("FAIL CASE CE: " + label + " (" + Default.ucd.getCodeAndName(source) + ")");
|
|
|
|
System.out.println("\t" + Default.ucd.getCode(source) + " => " + Default.ucd.getCode(casedCp));
|
|
|
|
System.out.println("\t" + Default.ucd.getCode(decomp) + " => " + Default.ucd.getCode(casedDecomp));
|
2002-03-15 00:34:46 +00:00
|
|
|
}
|
|
|
|
return false;
|
2001-12-13 23:36:29 +00:00
|
|
|
}
|
2002-03-15 00:34:46 +00:00
|
|
|
return true;
|
2001-12-13 23:36:29 +00:00
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2002-03-15 00:34:46 +00:00
|
|
|
public static final String IDN_DIR = BASE_DIR + "\\IDN\\";
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
/*
|
2002-04-23 01:59:16 +00:00
|
|
|
System.out.println(Default.ucd.toString(0x0387));
|
|
|
|
System.out.println(Default.ucd.toString(0x00B7));
|
|
|
|
System.out.println(Default.ucd.toString(0x03a3));
|
|
|
|
System.out.println(Default.ucd.toString(0x03c2));
|
|
|
|
System.out.println(Default.ucd.toString(0x03c3));
|
|
|
|
System.out.println(Default.ucd.toString(0x0069));
|
|
|
|
System.out.println(Default.ucd.toString(0x0130));
|
|
|
|
System.out.println(Default.ucd.toString(0x0131));
|
|
|
|
System.out.println(Default.ucd.toString(0x0345));
|
2001-08-30 20:50:18 +00:00
|
|
|
*/
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
static void checkAgainstOtherVersion(String otherVersion) {
|
2002-04-23 01:59:16 +00:00
|
|
|
Default.setUCD();
|
2001-08-30 20:50:18 +00:00
|
|
|
UCD ucd2 = UCD.make(otherVersion);
|
|
|
|
for (int cp = 0; cp <= 0x10FFFF; ++cp) {
|
2002-04-23 01:59:16 +00:00
|
|
|
UData curr = Default.ucd.get(cp, true);
|
2001-08-30 20:50:18 +00:00
|
|
|
UData other = ucd2.get(cp, true);
|
|
|
|
if (!curr.equals(other)) {
|
2002-04-23 01:59:16 +00:00
|
|
|
System.out.println("Difference at " + Default.ucd.getCodeAndName(cp));
|
2001-08-30 20:50:18 +00:00
|
|
|
System.out.println(curr);
|
|
|
|
System.out.println(curr);
|
|
|
|
System.out.println();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
static void generateXML() throws IOException {
|
2002-04-23 01:59:16 +00:00
|
|
|
Default.setUCD();
|
2001-08-30 20:50:18 +00:00
|
|
|
String filename = "UCD.xml";
|
2002-07-30 09:57:18 +00:00
|
|
|
PrintWriter log = Utility.openPrintWriter(filename, Utility.LATIN1_UNIX);
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
//log.println('\uFEFF');
|
|
|
|
log.println("<ucd>");
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
for (int cp = 0; cp <= 0x10FFFF; ++cp) {
|
|
|
|
Utility.dot(cp);
|
2002-04-23 01:59:16 +00:00
|
|
|
if (!Default.ucd.isRepresented(cp)) continue;
|
2001-08-30 20:50:18 +00:00
|
|
|
if (cp == 0xE0026 || cp == 0x20000) {
|
|
|
|
System.out.println("debug");
|
|
|
|
}
|
2002-04-23 01:59:16 +00:00
|
|
|
log.println(Default.ucd.toString(cp));
|
2001-08-30 20:50:18 +00:00
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
log.println("</ucd>");
|
|
|
|
log.close();
|
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
static final byte MIXED = (byte)(UNCASED + 1);
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
public static void checkCase() throws IOException {
|
2002-04-23 01:59:16 +00:00
|
|
|
Default.setUCD();
|
2001-08-30 20:50:18 +00:00
|
|
|
Utility.fixDot();
|
|
|
|
System.out.println("checkCase");
|
2001-10-25 20:33:46 +00:00
|
|
|
|
|
|
|
String test = "The qui'ck br\u2019own 'fox jum\u00ADped ov\u200Ber th\u200Ce lazy dog.";
|
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
String ttest = Default.ucd.getCase(test, FULL, TITLE);
|
2001-10-25 20:33:46 +00:00
|
|
|
|
2002-07-30 09:57:18 +00:00
|
|
|
PrintWriter titleTest = Utility.openPrintWriter("TestTitle.txt", Utility.LATIN1_UNIX);
|
2001-10-25 20:33:46 +00:00
|
|
|
titleTest.println(test);
|
|
|
|
titleTest.println(ttest);
|
|
|
|
titleTest.close();
|
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
System.out.println(Default.ucd.getCase("ABC,DE'F G\u0308H", FULL, TITLE));
|
2001-08-30 20:50:18 +00:00
|
|
|
String fileName = "CaseDifferences.txt";
|
2002-07-30 09:57:18 +00:00
|
|
|
PrintWriter log = Utility.openPrintWriter(fileName, Utility.LATIN1_UNIX);
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
for (int cp = 0; cp <= 0x10FFFF; ++cp) {
|
|
|
|
Utility.dot(cp);
|
2002-04-23 01:59:16 +00:00
|
|
|
if (!Default.ucd.isRepresented(cp) || Default.ucd.isPUA(cp)) continue;
|
2001-08-30 20:50:18 +00:00
|
|
|
if (cp == '\u3371') {
|
|
|
|
System.out.println("debug");
|
|
|
|
}
|
2002-04-23 01:59:16 +00:00
|
|
|
String x = Default.nfkd.normalize(cp);
|
|
|
|
String xu = Default.ucd.getCase(x, FULL, UPPER);
|
|
|
|
String xl = Default.ucd.getCase(x, FULL, LOWER);
|
|
|
|
String xt = Default.ucd.getCase(x, FULL, TITLE);
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
byte caseCat = MIXED;
|
|
|
|
if (xu.equals(xl)) caseCat = UNCASED;
|
|
|
|
else if (x.equals(xl)) caseCat = LOWER;
|
|
|
|
else if (x.equals(xu)) caseCat = UPPER;
|
|
|
|
else if (x.equals(xt)) caseCat = TITLE;
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
byte cat = Default.ucd.getCategory(cp);
|
|
|
|
boolean otherLower = Default.ucd.getBinaryProperty(cp, Other_Lowercase);
|
|
|
|
boolean otherUpper = Default.ucd.getBinaryProperty(cp, Other_Uppercase);
|
2001-08-30 20:50:18 +00:00
|
|
|
byte oldCaseCat = (cat == Lu || otherUpper) ? UPPER
|
|
|
|
: (cat == Ll || otherLower) ? LOWER
|
|
|
|
: (cat == Lt) ? TITLE
|
|
|
|
: UNCASED;
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
if (caseCat != oldCaseCat) {
|
|
|
|
log.println(UTF32.valueOf32(cp)
|
2001-08-31 00:30:17 +00:00
|
|
|
+ "\t" + names[caseCat]
|
2001-08-30 20:50:18 +00:00
|
|
|
+ "\t" + names[oldCaseCat]
|
2002-04-23 01:59:16 +00:00
|
|
|
+ "\t" + Default.ucd.getCategoryID_fromIndex(cat)
|
2001-08-31 00:30:17 +00:00
|
|
|
+ "\t" + lowerNames[otherLower ? 1 : 0]
|
|
|
|
+ "\t" + upperNames[otherUpper ? 1 : 0]
|
2002-04-23 01:59:16 +00:00
|
|
|
+ "\t" + Default.ucd.getCodeAndName(cp)
|
|
|
|
+ "\t" + Default.ucd.getCodeAndName(x)
|
|
|
|
+ "\t" + Default.ucd.getCodeAndName(xu)
|
|
|
|
+ "\t" + Default.ucd.getCodeAndName(xl)
|
|
|
|
+ "\t" + Default.ucd.getCodeAndName(xt)
|
2001-08-30 20:50:18 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
log.close();
|
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-11-13 02:31:55 +00:00
|
|
|
public static void checkCase2(boolean longForm) throws IOException {
|
2002-04-23 01:59:16 +00:00
|
|
|
Default.setUCD();
|
2001-08-30 20:50:18 +00:00
|
|
|
Utility.fixDot();
|
|
|
|
System.out.println("checkCase");
|
2001-11-13 02:31:55 +00:00
|
|
|
|
|
|
|
/*String tx1 = "\u0391\u0342\u0345";
|
|
|
|
String ux1 = "\u0391\u0342\u0399";
|
|
|
|
String ctx1 = nfc.normalize(tx1);
|
|
|
|
String ctx2 = nfc.normalize(ux1); // wrong??
|
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
//System.out.println(Default.ucd.getCase("ABC,DE'F G\u0308H", FULL, TITLE));
|
2001-11-13 02:31:55 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
String fileName = "CaseNormalizationDifferences.txt";
|
2002-07-30 09:57:18 +00:00
|
|
|
PrintWriter log = Utility.openPrintWriter(fileName, Utility.LATIN1_UNIX);
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
log.println("Differences between case(normalize(cp)) and normalize(case(cp))");
|
|
|
|
log.println("u, l, t - upper, lower, title");
|
|
|
|
log.println("c, d - nfc, nfd");
|
2001-11-13 02:31:55 +00:00
|
|
|
|
|
|
|
//Utility.DOTMASK = 0x7F;
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
for (int cp = 0; cp <= 0x10FFFF; ++cp) {
|
|
|
|
Utility.dot(cp);
|
2002-04-23 01:59:16 +00:00
|
|
|
if (!Default.ucd.isRepresented(cp) || Default.ucd.isPUA(cp)) continue;
|
2001-11-13 02:31:55 +00:00
|
|
|
if (cp == '\u0130') {
|
2001-08-30 20:50:18 +00:00
|
|
|
System.out.println("debug");
|
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
String x = UTF32.valueOf32(cp);
|
2002-04-23 01:59:16 +00:00
|
|
|
String dx = Default.nfd.normalize(cp);
|
|
|
|
String cx = Default.nfc.normalize(cp);
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
String ux = Default.ucd.getCase(x, FULL, UPPER);
|
|
|
|
String lx = Default.ucd.getCase(x, FULL, LOWER);
|
|
|
|
String tx = Default.ucd.getCase(x, FULL, TITLE);
|
2001-11-13 02:31:55 +00:00
|
|
|
|
|
|
|
if (x.equals(dx) && dx.equals(cx) && cx.equals(ux) && ux.equals(lx) && lx.equals(tx)) continue;
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
String cux = Default.nfc.normalize(ux);
|
|
|
|
String clx = Default.nfc.normalize(lx);
|
|
|
|
String ctx = Default.nfc.normalize(tx);
|
2001-11-13 02:31:55 +00:00
|
|
|
|
|
|
|
if (x.equals(cx)) {
|
|
|
|
boolean needBreak = false;
|
|
|
|
if (!clx.equals(lx)) needBreak = true;
|
|
|
|
if (!ctx.equals(tx)) needBreak = true;
|
|
|
|
if (!cux.equals(ux)) needBreak = true;
|
|
|
|
|
|
|
|
if (needBreak) {
|
|
|
|
log.println("# Was not NFC:");
|
|
|
|
log.println(
|
|
|
|
"## " + Utility.hex(x) + "; "
|
|
|
|
+ Utility.hex(lx) + "; "
|
|
|
|
+ Utility.hex(tx) + "; "
|
|
|
|
+ Utility.hex(ux) + "; # "
|
2002-04-23 01:59:16 +00:00
|
|
|
+ Default.ucd.getName(x));
|
2001-11-13 02:31:55 +00:00
|
|
|
log.println("# should be:");
|
|
|
|
log.println(
|
|
|
|
Utility.hex(x) + "; "
|
|
|
|
+ Utility.hex(clx) + "; "
|
|
|
|
+ Utility.hex(ctx) + "; "
|
|
|
|
+ Utility.hex(cux) + "; # "
|
2002-04-23 01:59:16 +00:00
|
|
|
+ Default.ucd.getName(x));
|
2001-11-13 02:31:55 +00:00
|
|
|
log.println();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
String dux = Default.nfd.normalize(ux);
|
|
|
|
String dlx = Default.nfd.normalize(lx);
|
|
|
|
String dtx = Default.nfd.normalize(tx);
|
2001-11-13 02:31:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String startdx = getMarks(dx, false);
|
|
|
|
String enddx = getMarks(dx, true);
|
|
|
|
|
|
|
|
String startdux = getMarks(dux, false);
|
|
|
|
String enddux = getMarks(dux, true);
|
|
|
|
|
|
|
|
String startdtx = getMarks(dtx, false);
|
|
|
|
String enddtx = getMarks(dtx, true);
|
|
|
|
|
|
|
|
String startdlx = getMarks(dlx, false);
|
|
|
|
String enddlx = getMarks(dlx, true);
|
|
|
|
|
|
|
|
// If the new marks don't occur in the old decomposition, we got a problem!
|
|
|
|
|
|
|
|
if (!startdx.startsWith(startdux) || !startdx.startsWith(startdtx) || !startdx.startsWith(startdlx)
|
|
|
|
|| !enddx.endsWith(enddux) || !enddx.endsWith(enddtx) || !enddx.endsWith(enddlx)) {
|
2002-04-23 01:59:16 +00:00
|
|
|
log.println("Combining Class Difference for " + Default.ucd.getCodeAndName(x));
|
|
|
|
log.println("x: " + Default.ucd.getCodeAndName(dx) + ", " + Utility.hex(startdx) + ", " + Utility.hex(enddx));
|
|
|
|
log.println("ux: " + Default.ucd.getCodeAndName(dux) + ", " + Utility.hex(startdux) + ", " + Utility.hex(enddux));
|
|
|
|
log.println("tx: " + Default.ucd.getCodeAndName(dtx) + ", " + Utility.hex(startdtx) + ", " + Utility.hex(enddtx));
|
|
|
|
log.println("lx: " + Default.ucd.getCodeAndName(dlx) + ", " + Utility.hex(startdlx) + ", " + Utility.hex(enddlx));
|
2001-11-13 02:31:55 +00:00
|
|
|
log.println();
|
|
|
|
}
|
|
|
|
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-11-13 02:31:55 +00:00
|
|
|
if (!longForm) continue;
|
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
String udx = Default.ucd.getCase(dx, FULL, UPPER);
|
|
|
|
String ldx = Default.ucd.getCase(dx, FULL, LOWER);
|
|
|
|
String tdx = Default.ucd.getCase(dx, FULL, TITLE);
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
String ucx = Default.ucd.getCase(cx, FULL, UPPER);
|
|
|
|
String lcx = Default.ucd.getCase(cx, FULL, LOWER);
|
|
|
|
String tcx = Default.ucd.getCase(cx, FULL, TITLE);
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
String dudx = Default.nfd.normalize(udx);
|
|
|
|
String dldx = Default.nfd.normalize(ldx);
|
|
|
|
String dtdx = Default.nfd.normalize(tdx);
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
String cucx = Default.nfc.normalize(ucx);
|
|
|
|
String clcx = Default.nfc.normalize(lcx);
|
|
|
|
String ctcx = Default.nfc.normalize(tcx);
|
2001-08-31 00:30:17 +00:00
|
|
|
|
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
if (!dux.equals(udx)
|
|
|
|
|| !dlx.equals(ldx)
|
|
|
|
|| !dtx.equals(tdx)
|
|
|
|
|| !cux.equals(ucx)
|
|
|
|
|| !clx.equals(lcx)
|
|
|
|
|| !ctx.equals(tcx)
|
|
|
|
|| !dux.equals(dudx)
|
|
|
|
|| !dlx.equals(dldx)
|
|
|
|
|| !dtx.equals(dtdx)
|
|
|
|
|| !cux.equals(cucx)
|
|
|
|
|| !clx.equals(clcx)
|
|
|
|
|| !ctx.equals(ctcx)
|
|
|
|
) {
|
|
|
|
log.println();
|
2002-04-23 01:59:16 +00:00
|
|
|
log.println("Difference at " + Default.ucd.getCodeAndName(cp));
|
|
|
|
if (!x.equals(ux)) log.println("\tu(cp):\t" + Default.ucd.getCodeAndName(ux));
|
|
|
|
if (!x.equals(lx)) log.println("\tl(cp):\t" + Default.ucd.getCodeAndName(lx));
|
|
|
|
if (!tx.equals(ux)) log.println("\tt(cp):\t" + Default.ucd.getCodeAndName(tx));
|
|
|
|
if (!x.equals(dx)) log.println("\td(cp):\t" + Default.ucd.getCodeAndName(dx));
|
|
|
|
if (!x.equals(cx)) log.println("\tc(cp):\t" + Default.ucd.getCodeAndName(cx));
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
if (!dux.equals(udx)) {
|
|
|
|
log.println();
|
2002-04-23 01:59:16 +00:00
|
|
|
log.println("\td(u(cp)):\t" + Default.ucd.getCodeAndName(dux));
|
|
|
|
log.println("\tu(d(cp)):\t" + Default.ucd.getCodeAndName(udx));
|
2001-08-30 20:50:18 +00:00
|
|
|
}
|
|
|
|
if (!dlx.equals(ldx)) {
|
|
|
|
log.println();
|
2002-04-23 01:59:16 +00:00
|
|
|
log.println("\td(l(cp)):\t" + Default.ucd.getCodeAndName(dlx));
|
|
|
|
log.println("\tl(d(cp)):\t" + Default.ucd.getCodeAndName(ldx));
|
2001-08-30 20:50:18 +00:00
|
|
|
}
|
|
|
|
if (!dtx.equals(tdx)) {
|
|
|
|
log.println();
|
2002-04-23 01:59:16 +00:00
|
|
|
log.println("\td(t(cp)):\t" + Default.ucd.getCodeAndName(dtx));
|
|
|
|
log.println("\tt(d(cp)):\t" + Default.ucd.getCodeAndName(tdx));
|
2001-08-30 20:50:18 +00:00
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
if (!cux.equals(ucx)) {
|
|
|
|
log.println();
|
2002-04-23 01:59:16 +00:00
|
|
|
log.println("\tc(u(cp)):\t" + Default.ucd.getCodeAndName(cux));
|
|
|
|
log.println("\tu(c(cp)):\t" + Default.ucd.getCodeAndName(ucx));
|
2001-08-30 20:50:18 +00:00
|
|
|
}
|
|
|
|
if (!clx.equals(lcx)) {
|
|
|
|
log.println();
|
2002-04-23 01:59:16 +00:00
|
|
|
log.println("\tc(l(cp)):\t" + Default.ucd.getCodeAndName(clx));
|
|
|
|
log.println("\tl(c(cp)):\t" + Default.ucd.getCodeAndName(lcx));
|
2001-08-30 20:50:18 +00:00
|
|
|
}
|
|
|
|
if (!ctx.equals(tcx)) {
|
|
|
|
log.println();
|
2002-04-23 01:59:16 +00:00
|
|
|
log.println("\tc(t(cp)):\t" + Default.ucd.getCodeAndName(ctx));
|
|
|
|
log.println("\tt(c(cp)):\t" + Default.ucd.getCodeAndName(tcx));
|
2001-08-30 20:50:18 +00:00
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
// ...........
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
if (!udx.equals(dudx)) {
|
|
|
|
log.println();
|
2002-04-23 01:59:16 +00:00
|
|
|
log.println("\tu(d(cp)):\t" + Default.ucd.getCodeAndName(udx));
|
|
|
|
log.println("\td(u(d(cp))):\t" + Default.ucd.getCodeAndName(dudx));
|
2001-08-30 20:50:18 +00:00
|
|
|
}
|
|
|
|
if (!ldx.equals(dldx)) {
|
|
|
|
log.println();
|
2002-04-23 01:59:16 +00:00
|
|
|
log.println("\tl(d(cp)):\t" + Default.ucd.getCodeAndName(ldx));
|
|
|
|
log.println("\td(l(d(cp))):\t" + Default.ucd.getCodeAndName(dldx));
|
2001-08-30 20:50:18 +00:00
|
|
|
}
|
|
|
|
if (!tdx.equals(dtdx)) {
|
|
|
|
log.println();
|
2002-04-23 01:59:16 +00:00
|
|
|
log.println("\tt(d(cp)):\t" + Default.ucd.getCodeAndName(tdx));
|
|
|
|
log.println("\td(t(d(cp))):\t" + Default.ucd.getCodeAndName(dtdx));
|
2001-08-30 20:50:18 +00:00
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
if (!ucx.equals(cucx)) {
|
|
|
|
log.println();
|
2002-04-23 01:59:16 +00:00
|
|
|
log.println("\tu(c(cp)):\t" + Default.ucd.getCodeAndName(ucx));
|
|
|
|
log.println("\tc(u(c(cp))):\t" + Default.ucd.getCodeAndName(cucx));
|
2001-08-30 20:50:18 +00:00
|
|
|
}
|
|
|
|
if (!lcx.equals(clcx)) {
|
|
|
|
log.println();
|
2002-04-23 01:59:16 +00:00
|
|
|
log.println("\tl(c(cp)):\t" + Default.ucd.getCodeAndName(lcx));
|
|
|
|
log.println("\tc(l(c(cp))):\t" + Default.ucd.getCodeAndName(clcx));
|
2001-08-30 20:50:18 +00:00
|
|
|
}
|
|
|
|
if (!tcx.equals(ctcx)) {
|
|
|
|
log.println();
|
2002-04-23 01:59:16 +00:00
|
|
|
log.println("\tt(c(cp)):\t" + Default.ucd.getCodeAndName(tcx));
|
|
|
|
log.println("\tc(t(c(cp))):\t" + Default.ucd.getCodeAndName(ctcx));
|
2001-08-30 20:50:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
log.close();
|
|
|
|
}
|
2001-11-13 02:31:55 +00:00
|
|
|
|
|
|
|
public static String getMarks(String s, boolean doEnd) {
|
|
|
|
int cp;
|
|
|
|
if (!doEnd) {
|
|
|
|
for (int i = 0; i < s.length(); i += UTF16.getCharCount(cp)) {
|
|
|
|
cp = UTF16.charAt(s, i);
|
2002-04-23 01:59:16 +00:00
|
|
|
int cc = Default.ucd.getCombiningClass(cp);
|
2001-11-13 02:31:55 +00:00
|
|
|
if (cc == 0) {
|
|
|
|
return s.substring(0, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (int i = s.length(); i > 0; i -= UTF16.getCharCount(cp)) {
|
|
|
|
cp = UTF16.charAt(s, i-1); // will go 2 before if necessary
|
2002-04-23 01:59:16 +00:00
|
|
|
int cc = Default.ucd.getCombiningClass(cp);
|
2001-11-13 02:31:55 +00:00
|
|
|
if (cc == 0) {
|
|
|
|
return s.substring(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
static final String names[] = {"LOWER", "TITLE", "UPPER", "(UNC)", "MIXED"};
|
2002-06-13 21:14:05 +00:00
|
|
|
static final String names2[] = {"LOWER", "TITLE", "UPPER", "FOLD"};
|
2001-08-30 20:50:18 +00:00
|
|
|
static final String lowerNames[] = {"", "Other_Lower"};
|
|
|
|
static final String upperNames[] = {"", "Other_Upper"};
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
public static void CheckCaseFold() {
|
2002-04-23 01:59:16 +00:00
|
|
|
Default.setUCD();
|
2001-08-30 20:50:18 +00:00
|
|
|
System.out.println("Checking Case Fold");
|
|
|
|
for (int cp = 0; cp <= 0x10FFFF; ++cp) {
|
|
|
|
Utility.dot(cp);
|
2002-04-23 01:59:16 +00:00
|
|
|
if (!Default.ucd.isAssigned(cp) || Default.ucd.isPUA(cp)) continue;
|
2002-06-13 21:14:05 +00:00
|
|
|
|
|
|
|
boolean failed = false;
|
2002-04-23 01:59:16 +00:00
|
|
|
String fullTest = Default.ucd.getCase(Default.ucd.getCase(cp, FULL, UPPER), FULL, LOWER);
|
|
|
|
String simpleTest = Default.ucd.getCase(Default.ucd.getCase(cp, SIMPLE, UPPER), SIMPLE, LOWER);
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
String full = Default.ucd.getCase(cp, FULL, FOLD);
|
|
|
|
String simple = Default.ucd.getCase(cp, SIMPLE, FOLD);
|
2002-06-13 21:14:05 +00:00
|
|
|
|
|
|
|
String realTest = "\u0360" + UTF16.valueOf(cp) + "\u0334";
|
|
|
|
|
|
|
|
int ccc = Default.ucd.getCombiningClass(cp);
|
|
|
|
|
2003-07-21 15:50:07 +00:00
|
|
|
for (byte style = FOLD; style < LIMIT_CASE; ++style) {
|
2002-06-13 21:14:05 +00:00
|
|
|
|
|
|
|
String fold_NFD = Default.nfd.normalize(Default.ucd.getCase(realTest, FULL, style));
|
|
|
|
String NFD_fold = Default.ucd.getCase(Default.nfd.normalize(realTest), FULL, style);
|
|
|
|
if (!fold_NFD.equals(NFD_fold)) {
|
|
|
|
Utility.fixDot();
|
|
|
|
System.out.println("Case check fails at " + Default.ucd.getCodeAndName(cp));
|
|
|
|
System.out.println("\t" + names2[style] + ", then NFD: " + Default.ucd.getCodeAndName(fold_NFD));
|
|
|
|
System.out.println("\tNFD, then " + names2[style] + ": " + Default.ucd.getCodeAndName(NFD_fold));
|
|
|
|
failed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
int ccc = Default.ucd.getCombiningClass(cp);
|
|
|
|
|
|
|
|
int cp2;
|
|
|
|
for (int i = 0; i < full.length(); i += UTF16.getCharCount(cp2)) {
|
|
|
|
cp2 = UTF16.charAt(full, i);
|
|
|
|
int ccc2 = Default.ucd.getCombiningClass(cp2);
|
|
|
|
if (ccc2 != ccc) {
|
|
|
|
System.out.println("Case fold CCC fails at " + Default.ucd.getCodeAndName(cp));
|
|
|
|
System.out.println("\tFull case folding:" + ccc2 + ", " + Default.ucd.getCodeAndName(full));
|
|
|
|
System.out.println("\tccc:" + ccc);
|
|
|
|
System.out.println("\tccc:" + ccc2 + ", " + Default.ucd.getCodeAndName(cp2));
|
|
|
|
failed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
if (!full.equals(fullTest)) {
|
|
|
|
Utility.fixDot();
|
2002-04-23 01:59:16 +00:00
|
|
|
System.out.println("Case fold fails at " + Default.ucd.getCodeAndName(cp));
|
|
|
|
System.out.println(" fullFold(ch): " + Default.ucd.getCodeAndName(full));
|
|
|
|
System.out.println(" fullUpper(fullLower(ch)): " + Default.ucd.getCodeAndName(fullTest));
|
2001-08-30 20:50:18 +00:00
|
|
|
failed = true;
|
|
|
|
}
|
|
|
|
if (!simple.equals(simpleTest)) {
|
|
|
|
Utility.fixDot();
|
2002-04-23 01:59:16 +00:00
|
|
|
if (!failed) System.out.println("Case fold fails at " + Default.ucd.getCodeAndName(cp));
|
|
|
|
System.out.println(" simpleFold(ch): " + Default.ucd.getCodeAndName(simple));
|
|
|
|
System.out.println(" simpleUpper(simpleLower(ch)): " + Default.ucd.getCodeAndName(simpleTest));
|
2001-08-30 20:50:18 +00:00
|
|
|
failed = true;
|
|
|
|
}
|
|
|
|
if (failed) System.out.println();
|
|
|
|
}
|
|
|
|
}
|
2001-12-13 23:36:29 +00:00
|
|
|
|
|
|
|
public static void compareBlueberry() {
|
2002-04-23 01:59:16 +00:00
|
|
|
Default.setUCD();
|
2001-12-13 23:36:29 +00:00
|
|
|
|
|
|
|
UnicodeSet NameStartChar = new UnicodeSet("[A-Z:_a-z\\u00C0-\\u02FF"
|
|
|
|
+ "\\u0370-\\u037D\\u037F-\\u2027\\u202A-\\u218F\\u2800-\\uD7FF"
|
|
|
|
+ "\\uE000-\\uFDCF\\uFDE0-\\uFFEF\\U00010000-\\U0010FFFF]");
|
|
|
|
System.out.println("NameStartChar:");
|
|
|
|
System.out.println("\t" + NameStartChar.toPattern(true));
|
|
|
|
|
|
|
|
UnicodeSet NameChar = new UnicodeSet("[-.0-9\\u00b7\\u0300-\\u036F]");
|
|
|
|
System.out.println("NameChar-:");
|
|
|
|
System.out.println("\t" + NameChar.toPattern(true));
|
|
|
|
NameChar.addAll(NameStartChar);
|
|
|
|
System.out.println("NameChar:");
|
|
|
|
System.out.println("\t" + NameChar.toPattern(true));
|
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
UnicodeProperty IDstart = DerivedProperty.make(Mod_ID_Start, Default.ucd);
|
|
|
|
UnicodeProperty IDcontinue = DerivedProperty.make(Mod_ID_Continue_NO_Cf, Default.ucd);
|
2001-12-13 23:36:29 +00:00
|
|
|
|
|
|
|
UnicodeSet IDContinueMinusNameChar = new UnicodeSet();
|
|
|
|
UnicodeSet IDStartMinusNameChar = new UnicodeSet();
|
|
|
|
UnicodeSet IDStartMinusNameStartChar = new UnicodeSet();
|
|
|
|
UnicodeSet UnassignedMinusNameChar = new UnicodeSet();
|
|
|
|
|
|
|
|
for (int cp = 0; cp < 0x10FFFF; ++cp) {
|
|
|
|
Utility.dot(cp);
|
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
if (Default.ucd.isPUA(cp)) continue;
|
|
|
|
if (!Default.ucd.isAssigned(cp) && !NameChar.contains(cp)) {
|
2001-12-13 23:36:29 +00:00
|
|
|
UnassignedMinusNameChar.add(cp);
|
|
|
|
} else if (IDcontinue.hasValue(cp) && !NameChar.contains(cp)) {
|
|
|
|
IDContinueMinusNameChar.add(cp);
|
|
|
|
} else if (IDstart.hasValue(cp)) {
|
|
|
|
if (!NameChar.contains(cp)) {
|
|
|
|
IDStartMinusNameChar.add(cp);
|
|
|
|
} else if (!NameStartChar.contains(cp)) {
|
|
|
|
IDStartMinusNameStartChar.add(cp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
System.out.println("IDContinueMinusNameChar: ");
|
|
|
|
System.out.println("\t" + IDContinueMinusNameChar.toPattern(true));
|
2002-04-23 01:59:16 +00:00
|
|
|
Utility.showSetNames("\t", IDContinueMinusNameChar, false, Default.ucd);
|
2001-12-13 23:36:29 +00:00
|
|
|
System.out.println("IDStartMinusNameChar: ");
|
|
|
|
System.out.println("\t" + IDStartMinusNameChar.toPattern(true));
|
|
|
|
System.out.println("IDStartMinusNameStartChar: ");
|
|
|
|
System.out.println("\t" + IDStartMinusNameStartChar.toPattern(true));
|
|
|
|
System.out.println("UnassignedMinusNameChar: ");
|
|
|
|
System.out.println("\t" + UnassignedMinusNameChar.toPattern(true));
|
|
|
|
}
|
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
public static void VerifyIDN() throws IOException {
|
2002-04-23 01:59:16 +00:00
|
|
|
Default.setUCD();
|
2001-08-30 20:50:18 +00:00
|
|
|
System.out.println("VerifyIDN");
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
System.out.println();
|
|
|
|
System.out.println("Checking Map");
|
|
|
|
System.out.println();
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
BitSet mappedOut = new BitSet();
|
|
|
|
int errorCount = verifyUTFMap(mappedOut);
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
BitSet unassigned = getIDNList("IDN-Unassigned.txt");
|
|
|
|
BitSet prohibited = getIDNList("IDN-Prohibited.txt");
|
|
|
|
BitSet guessSet = guessIDN();
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
System.out.println();
|
|
|
|
System.out.println("Checking Prohibited and Unassigned");
|
|
|
|
System.out.println();
|
|
|
|
for (int cp = 0; cp <= 0x10FFFF; ++cp) {
|
2001-09-19 23:33:52 +00:00
|
|
|
Utility.dot(cp);
|
2001-08-30 20:50:18 +00:00
|
|
|
if (mappedOut.get(cp)) continue;
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
boolean ucdUnassigned = !Default.ucd.isAllocated(cp);
|
2001-08-30 20:50:18 +00:00
|
|
|
boolean idnUnassigned = unassigned.get(cp);
|
|
|
|
boolean guess = guessSet.get(cp);
|
|
|
|
boolean idnProhibited = prohibited.get(cp);
|
|
|
|
|
|
|
|
if (ucdUnassigned && !idnUnassigned) {
|
2001-09-19 23:33:52 +00:00
|
|
|
showError("?UCD Unassigned but not IDN Unassigned", cp, "");
|
2001-08-30 20:50:18 +00:00
|
|
|
++errorCount;
|
|
|
|
} else if (!ucdUnassigned && idnUnassigned) {
|
2001-09-19 23:33:52 +00:00
|
|
|
showError("?Not UCD Unassigned but IDN Unassigned", cp, "");
|
2001-08-30 20:50:18 +00:00
|
|
|
++errorCount;
|
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
if (idnProhibited && unassigned.get(cp)) {
|
2001-09-19 23:33:52 +00:00
|
|
|
showError("?Both IDN Unassigned AND IDN Prohibited", cp, "");
|
2001-08-30 20:50:18 +00:00
|
|
|
++errorCount;
|
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
if (guess && !idnProhibited) {
|
2001-09-19 23:33:52 +00:00
|
|
|
showError("?UCD ?prohibited? but not IDN Prohibited ", cp, "");
|
2001-08-30 20:50:18 +00:00
|
|
|
++errorCount;
|
|
|
|
} else if (!guess && idnProhibited) {
|
2001-09-19 23:33:52 +00:00
|
|
|
showError("?Not UCD ?prohibited? but IDN Prohibited ", cp, "");
|
2001-08-30 20:50:18 +00:00
|
|
|
++errorCount;
|
|
|
|
}
|
2001-09-19 23:33:52 +00:00
|
|
|
|
|
|
|
if (cp == 0x3131) {
|
|
|
|
System.out.println("Debug: " + idnProhibited
|
|
|
|
+ ", " + idnUnassigned
|
2002-05-31 01:41:04 +00:00
|
|
|
+ ", " + !Default.nfkd.isNormalized(cp)
|
2002-04-23 01:59:16 +00:00
|
|
|
+ ", " + Default.ucd.getCodeAndName(Default.nfkc.normalize(cp))
|
|
|
|
+ ", " + Default.ucd.getCodeAndName(Default.nfc.normalize(cp)));
|
2001-09-19 23:33:52 +00:00
|
|
|
}
|
|
|
|
|
2002-05-31 01:41:04 +00:00
|
|
|
if (!idnProhibited && ! idnUnassigned && !Default.nfkd.isNormalized(cp)) {
|
2002-04-23 01:59:16 +00:00
|
|
|
String kc = Default.nfkc.normalize(cp);
|
|
|
|
String c = Default.nfc.normalize(cp);
|
2001-09-19 23:33:52 +00:00
|
|
|
if (kc.equals(c)) continue;
|
|
|
|
int cp2;
|
|
|
|
boolean excluded = false;
|
|
|
|
for (int j = 0; j < kc.length(); j += UTF16.getCharCount(cp2)) {
|
|
|
|
cp2 = UTF16.charAt(kc, j);
|
|
|
|
if (prohibited.get(cp2)) {
|
|
|
|
showError("Prohibited with NFKC, but output with NFC", cp, "");
|
|
|
|
excluded = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!excluded) {
|
2002-04-23 01:59:16 +00:00
|
|
|
showError("Remapped to core abstract character with NFKC (but not NFC)", cp, ""); // , "\t=> " + Default.ucd.getCodeAndName(kc));
|
2001-09-19 23:33:52 +00:00
|
|
|
}
|
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
}
|
2001-09-19 23:33:52 +00:00
|
|
|
System.out.println("Writing IDNCheck.txt");
|
|
|
|
|
|
|
|
|
2002-07-30 09:57:18 +00:00
|
|
|
PrintWriter log = Utility.openPrintWriter("IDNCheck.txt", Utility.LATIN1_UNIX);
|
2001-09-19 23:33:52 +00:00
|
|
|
log.println("IDN Check");
|
|
|
|
log.println("Total Errors: " + errorCount);
|
|
|
|
|
|
|
|
Iterator it = idnMap.keySet().iterator();
|
|
|
|
while (it.hasNext()) {
|
|
|
|
String description = (String) it.next();
|
|
|
|
Map map = (Map) idnMap.get(description);
|
|
|
|
log.println();
|
|
|
|
log.println(description);
|
|
|
|
log.println("Total: " + map.size());
|
|
|
|
log.println();
|
|
|
|
|
|
|
|
Iterator it2 = map.keySet().iterator();
|
|
|
|
while (it2.hasNext()) {
|
|
|
|
Object key = it2.next();
|
|
|
|
String line = (String) map.get(key);
|
|
|
|
log.println(" " + line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
log.close();
|
2001-08-30 20:50:18 +00:00
|
|
|
}
|
2001-09-19 23:33:52 +00:00
|
|
|
|
2002-03-15 00:34:46 +00:00
|
|
|
static Map idnMap = new java.util.HashMap();
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-09-19 23:33:52 +00:00
|
|
|
static void showError(String description, int cp, String option) {
|
|
|
|
Map probe = (Map) idnMap.get(description);
|
|
|
|
if (probe == null) {
|
|
|
|
probe = new TreeMap();
|
|
|
|
idnMap.put(description, probe);
|
|
|
|
}
|
2002-04-23 01:59:16 +00:00
|
|
|
probe.put(new Integer(cp), Default.ucd.getCodeAndName(cp) + " (" + Default.ucd.getCategoryID(cp) + ")" + option);
|
2001-08-30 20:50:18 +00:00
|
|
|
}
|
2002-06-22 01:21:11 +00:00
|
|
|
|
|
|
|
static void showDifferences(PrintWriter log, UnicodeSet s1, String name1, UnicodeSet s2, String name2, boolean both) {
|
|
|
|
if (!s1.equals(s2)) {
|
|
|
|
log.println();
|
|
|
|
log.println("In " + name1 + ", but NOT " + name2);
|
|
|
|
Utility.showSetNames(log," ", new UnicodeSet(s1).removeAll(s2), false, false, Default.ucd);
|
|
|
|
log.println();
|
|
|
|
log.println("NOT in " + name1 + ", but in " + name2);
|
|
|
|
Utility.showSetNames(log," ", new UnicodeSet(s2).removeAll(s1), false, false, Default.ucd);
|
|
|
|
log.println();
|
|
|
|
if (both) {
|
|
|
|
log.println("In both " + name1 + " AND " + name2);
|
|
|
|
Utility.showSetNames(log," ", new UnicodeSet(s2).retainAll(s1), false, false, Default.ucd);
|
|
|
|
log.println();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2002-06-22 01:21:11 +00:00
|
|
|
public static void genIDN() throws IOException {
|
|
|
|
PrintWriter out = new PrintWriter(System.out);
|
|
|
|
Default.setUCD();
|
2002-07-30 09:57:18 +00:00
|
|
|
PrintWriter log = Utility.openPrintWriter("IDN-tables.txt", Utility.LATIN1_UNIX);
|
2002-06-22 01:21:11 +00:00
|
|
|
|
|
|
|
/*UnicodeSet y = UnifiedBinaryProperty.make(CATEGORY + FORMAT).getSet();
|
|
|
|
UnicodeSet x = new UnicodeSet(0xE0001,0xE007F).retainAll(y);
|
|
|
|
|
|
|
|
System.out.println("y: " + y.toPattern(true));
|
|
|
|
System.out.println("x: " + x.toPattern(true));
|
|
|
|
Utility.showSetNames(out, "* ", x, false, true, Default.ucd);
|
|
|
|
out.flush();
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
// table1
|
|
|
|
System.out.println("Getting Basics");
|
|
|
|
UnicodeSet unassigned = UnifiedBinaryProperty.make(CATEGORY + UNASSIGNED).getSet();
|
|
|
|
System.out.print(".");
|
|
|
|
UnicodeSet lineSeparators = UnifiedBinaryProperty.make(CATEGORY+LINE_SEPARATOR).getSet();
|
|
|
|
System.out.print(".");
|
|
|
|
UnicodeSet paraSeparators = UnifiedBinaryProperty.make(CATEGORY+PARAGRAPH_SEPARATOR).getSet();
|
|
|
|
System.out.print(".");
|
|
|
|
UnicodeSet spaceSeparators = UnifiedBinaryProperty.make(CATEGORY+SPACE_SEPARATOR).getSet();
|
|
|
|
System.out.print(".");
|
|
|
|
UnicodeSet noncharacters = UnifiedBinaryProperty.make(BINARY_PROPERTIES + Noncharacter_Code_Point).getSet();
|
|
|
|
System.out.print(".");
|
|
|
|
UnicodeSet deprecated = UnifiedBinaryProperty.make(BINARY_PROPERTIES + Deprecated).getSet();
|
|
|
|
System.out.print(".");
|
|
|
|
UnicodeSet format = UnifiedBinaryProperty.make(CATEGORY + FORMAT).getSet();
|
|
|
|
System.out.print(".");
|
|
|
|
UnicodeSet bidi_control = UnifiedBinaryProperty.make(BINARY_PROPERTIES+Bidi_Control).getSet();
|
|
|
|
System.out.print(".");
|
|
|
|
UnicodeSet binary_IDS = UnifiedBinaryProperty.make(BINARY_PROPERTIES+IDS_BinaryOperator).getSet();
|
|
|
|
System.out.print(".");
|
|
|
|
UnicodeSet trinary_IDS = UnifiedBinaryProperty.make(BINARY_PROPERTIES+IDS_TrinaryOperator).getSet();
|
|
|
|
System.out.print(".");
|
|
|
|
UnicodeSet whitespace = UnifiedBinaryProperty.make(BINARY_PROPERTIES+White_space).getSet();
|
|
|
|
whitespace.addAll(spaceSeparators); // bug.
|
|
|
|
System.out.print(".");
|
|
|
|
|
|
|
|
UnicodeSet defaultIgnorable = UnifiedBinaryProperty.make(DERIVED + DefaultIgnorable).getSet();
|
|
|
|
System.out.print(".");
|
|
|
|
|
|
|
|
UnicodeSet privateUse = UnifiedBinaryProperty.make(CATEGORY+PRIVATE_USE).getSet();
|
|
|
|
System.out.print(".");
|
|
|
|
UnicodeSet control = UnifiedBinaryProperty.make(CATEGORY+Cc).getSet();
|
|
|
|
System.out.print(".");
|
|
|
|
UnicodeSet surrogate = UnifiedBinaryProperty.make(CATEGORY+SURROGATE).getSet();
|
|
|
|
|
|
|
|
System.out.println("Building Sets");
|
|
|
|
// small test:
|
|
|
|
|
|
|
|
if (DEBUG) {
|
|
|
|
showDifferences(log, whitespace, "White_Space",
|
|
|
|
new UnicodeSet(spaceSeparators).addAll(lineSeparators).addAll(paraSeparators), "Separators", true);
|
|
|
|
|
|
|
|
showDifferences(log, UnifiedBinaryProperty.make(DERIVED + ID_Start).getSet(), "ID_Start",
|
|
|
|
UnifiedBinaryProperty.make(DERIVED + Mod_ID_Start).getSet(), "XID_Start", false);
|
|
|
|
|
|
|
|
showDifferences(log, UnifiedBinaryProperty.make(DERIVED + ID_Continue_NO_Cf).getSet(), "ID_Continue",
|
|
|
|
UnifiedBinaryProperty.make(DERIVED + Mod_ID_Continue_NO_Cf).getSet(), "XID_Continue", false);
|
|
|
|
|
|
|
|
System.out.println("Done with Test");
|
|
|
|
}
|
|
|
|
|
|
|
|
UnicodeSet A1 = new UnicodeSet(unassigned).removeAll(noncharacters);
|
|
|
|
|
|
|
|
// special code for B1
|
|
|
|
|
|
|
|
/*
|
|
|
|
B1, old
|
|
|
|
00AD; SOFT HYPHEN
|
|
|
|
1806; MONGOLIAN TODO SOFT HYPHEN
|
|
|
|
180B; MONGOLIAN FREE VARIATION SELECTOR ONE
|
|
|
|
180C; MONGOLIAN FREE VARIATION SELECTOR TWO
|
|
|
|
180D; MONGOLIAN FREE VARIATION SELECTOR THREE
|
|
|
|
200B; ZERO WIDTH SPACE
|
|
|
|
200C; ZERO WIDTH NON-JOINER
|
|
|
|
200D; ZERO WIDTH JOINER
|
|
|
|
FEFF; ZERO WIDTH NO-BREAK SPACE
|
|
|
|
*/
|
|
|
|
|
|
|
|
UnicodeSet B1 = new UnicodeSet().add(0xAD).add(0x1806).add(0x034F); // START WITH soft hyphen, mongolian soft hyphen, grapheme joiner
|
|
|
|
// THEN ADD default ignorables or format characters that are *variation* or *zero width*
|
|
|
|
UnicodeSet temp = new UnicodeSet(defaultIgnorable).addAll(format).addAll(spaceSeparators)
|
|
|
|
.removeAll(surrogate).removeAll(control); // remove some just to avoid clutter when debugging.
|
|
|
|
UnicodeSetIterator it = new UnicodeSetIterator(temp);
|
|
|
|
while(it.next()) {
|
|
|
|
if (!Default.ucd.isAssigned(it.codepoint)) continue;
|
|
|
|
String name = Default.ucd.getName(it.codepoint);
|
|
|
|
System.out.print(Default.ucd.getCodeAndName(it.codepoint));
|
|
|
|
|
|
|
|
if (name.indexOf("VARIATION") >= 0 || name.indexOf("ZERO") >= 0
|
|
|
|
|| name.indexOf("WORD JOINER") >= 0) {
|
|
|
|
B1.add(it.codepoint);
|
|
|
|
System.out.print("*");
|
|
|
|
}
|
|
|
|
System.out.println();
|
|
|
|
}
|
|
|
|
|
|
|
|
UnicodeSet C1 = new UnicodeSet(whitespace).removeAll(control).removeAll(lineSeparators)
|
|
|
|
.removeAll(paraSeparators);
|
|
|
|
|
|
|
|
UnicodeSet C2 = new UnicodeSet(defaultIgnorable).removeAll(unassigned).removeAll(surrogate)
|
|
|
|
.addAll(control).addAll(format).addAll(lineSeparators).addAll(paraSeparators);
|
|
|
|
|
|
|
|
UnicodeSet C3 = new UnicodeSet(privateUse);
|
|
|
|
|
|
|
|
UnicodeSet C4 = new UnicodeSet(noncharacters);
|
|
|
|
|
|
|
|
UnicodeSet C5 = new UnicodeSet(surrogate);
|
|
|
|
|
|
|
|
UnicodeSet C6 = new UnicodeSet(0xFFF9, 0xFFFC).add(0xFFFD);
|
|
|
|
|
|
|
|
UnicodeSet C7 = new UnicodeSet(binary_IDS).addAll(trinary_IDS);
|
|
|
|
|
|
|
|
UnicodeSet C8 = new UnicodeSet(deprecated).addAll(bidi_control);
|
|
|
|
|
|
|
|
UnicodeSet C9 = new UnicodeSet(0xE0001,0xE007F).retainAll(format);
|
|
|
|
//Utility.showSetNames(out, "\t&&& ", C9, false, true, Default.ucd);
|
|
|
|
//out.flush();
|
|
|
|
|
|
|
|
|
|
|
|
// FIX UP SETS!!
|
|
|
|
B1.removeAll(C6);
|
|
|
|
B1.removeAll(C8);
|
|
|
|
B1.removeAll(C9);
|
|
|
|
|
|
|
|
C1.removeAll(B1);
|
|
|
|
|
|
|
|
C2.removeAll(B1);
|
|
|
|
C2.removeAll(C6);
|
|
|
|
C2.removeAll(C8);
|
|
|
|
C2.removeAll(C9);
|
|
|
|
|
|
|
|
System.out.println("Check that A1, B1, C1..9 are disjoint");
|
|
|
|
|
|
|
|
UnicodeSet[] test = {A1, B1, C1, C2, C3, C4, C5, C6, C7, C8, C9};
|
|
|
|
String[] testNames = {"A1", "B1", "C1", "C2", "C3", "C4", "C5", "C6", "C7", "C8", "C9"};
|
|
|
|
UnicodeSet union = new UnicodeSet();
|
|
|
|
|
|
|
|
for (int i = 0; i < test.length; ++i) {
|
|
|
|
union.addAll(test[i]);
|
|
|
|
for (int j = i + 1; j < test.length; ++j) {
|
|
|
|
if (test[i].containsNone(test[j])) continue;
|
|
|
|
log.println(testNames[i] + " and " + testNames[j] + " intersect!");
|
|
|
|
UnicodeSet intersection = new UnicodeSet(test[i]).retainAll(test[j]);
|
|
|
|
Utility.showSetNames(log," ", intersection, false, true, Default.ucd);
|
|
|
|
log.println();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
System.out.println("Check that union works");
|
|
|
|
|
|
|
|
UnicodeSet[] badChars = {unassigned, noncharacters, deprecated, format,
|
|
|
|
control, surrogate, privateUse, binary_IDS, trinary_IDS, whitespace, defaultIgnorable,
|
|
|
|
lineSeparators, paraSeparators, spaceSeparators};
|
|
|
|
UnicodeSet badCharUnion = new UnicodeSet();
|
|
|
|
for (int i = 0; i < badChars.length; ++i) {
|
|
|
|
badCharUnion.addAll(badChars[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
showDifferences(log, union, "(A1+B1+C1-C9)",
|
|
|
|
badCharUnion,
|
|
|
|
"(Whitespace+Deprecated+DefaultIgnorable+Separator+Other (cont/format/surr/priv/unass))", false);
|
|
|
|
|
|
|
|
System.out.println("Generating B2, B3");
|
|
|
|
|
|
|
|
log.println("Generating B2, B3");
|
|
|
|
Map B2 = new TreeMap();
|
|
|
|
Map B3 = new TreeMap();
|
|
|
|
Integer tempInteger = null;
|
|
|
|
|
|
|
|
for (int i = 0; i < 0x10FFFF; ++i) {
|
|
|
|
int cat = Default.ucd.getCategory(i);
|
|
|
|
if (!Default.ucd.isAssigned(i)) continue;
|
|
|
|
//if (cat == Cc || cat == Cf || cat == Co || cat == Cn) continue; // we can skip these
|
|
|
|
//if (Default.ucd.hasComputableName(i)) continue;
|
|
|
|
tempInteger = null;
|
|
|
|
|
|
|
|
String original = UTF16.valueOf(i);
|
|
|
|
String caseFold = Default.ucd.getCase(i, FULL, FOLD);
|
|
|
|
if (!original.equals(caseFold)) {
|
|
|
|
tempInteger = new Integer(i);
|
|
|
|
B2.put(tempInteger, caseFold);
|
|
|
|
B3.put(tempInteger, caseFold);
|
|
|
|
}
|
|
|
|
|
|
|
|
String b = Default.nfkc.normalize(caseFold);
|
|
|
|
String c = Default.nfkc.normalize(Default.ucd.getCase(b, FULL, FOLD));
|
|
|
|
|
|
|
|
if (!c.equals(b)) {
|
|
|
|
if (tempInteger != null) {
|
|
|
|
if (DEBUG) {
|
|
|
|
log.println("Possible Conflict");
|
|
|
|
log.println(" " + Default.ucd.getCodeAndName(i));
|
|
|
|
log.println(" => " + Default.ucd.getCodeAndName(caseFold));
|
|
|
|
log.println(" => " + Default.ucd.getCodeAndName(c));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
tempInteger = new Integer(i);
|
|
|
|
if (DEBUG) {
|
|
|
|
log.println(" " + Default.ucd.getCodeAndName(i));
|
|
|
|
log.println(" => " + Default.ucd.getCodeAndName(c));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (DEBUG) log.println();
|
|
|
|
B2.put(tempInteger, c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// PRINTOUT
|
|
|
|
|
|
|
|
printIDN_Table(log, "A.1", "Unassigned code points in Unicode " + Default.ucd.getVersion(), A1);
|
|
|
|
printIDN_Table(log, "B.1", "Commonly mapped to nothing", B1);
|
|
|
|
|
|
|
|
printIDN_Map(log, "B.2", "Mapping for lowercase used with NFKC", B2, B3);
|
|
|
|
|
|
|
|
printIDN_Map(log, "B.3", "Mapping for lowercase used with no normalization", B3, B2);
|
|
|
|
|
|
|
|
printIDN_Table(log, "C.1", "Space characters", C1);
|
|
|
|
printIDN_Table(log, "C.2", "Control characters", C2);
|
|
|
|
printIDN_Table(log, "C.3", "Private use", C3);
|
|
|
|
printIDN_Table(log, "C.4", "Non-character code points", C4);
|
|
|
|
printIDN_Table(log, "C.5", "Surrogate codes", C5);
|
|
|
|
printIDN_Table(log, "C.6", "Inappropriate for plain text", C6);
|
|
|
|
printIDN_Table(log, "C.7", "Inappropriate for canonical representation", C7);
|
|
|
|
printIDN_Table(log, "C.8", "Change display properties (or deprecated)", C8);
|
|
|
|
printIDN_Table(log, "C.9", "Tagging characters", C9);
|
|
|
|
|
|
|
|
System.out.println("Done");
|
|
|
|
log.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void printIDN_Map(PrintWriter log, String tableNumber, String description, Map map, Map other) {
|
|
|
|
System.out.println(tableNumber+ " " + description);
|
|
|
|
log.println("");
|
|
|
|
log.println(tableNumber+ " " + description);
|
|
|
|
log.println("");
|
|
|
|
log.println("----- Start Table " + tableNumber + " -----");
|
|
|
|
Iterator it = map.keySet().iterator();
|
|
|
|
while(it.hasNext()) {
|
|
|
|
Integer key = (Integer) it.next();
|
|
|
|
String value = (String) map.get(key);
|
|
|
|
int cp = key.intValue();
|
|
|
|
log.println(Utility.hex(cp, 4) + "; " + Utility.hex(value, 4) + "; "
|
|
|
|
+ (!value.equals(other.get(key))? "***" : "")
|
|
|
|
+ Default.ucd.getName(cp));
|
|
|
|
}
|
|
|
|
log.println("----- End Table " + tableNumber + " -----");
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void printIDN_Table(PrintWriter log, String tableNumber, String description, UnicodeSet set) {
|
|
|
|
System.out.println(tableNumber+ " " + description);
|
|
|
|
log.println("");
|
|
|
|
log.println(tableNumber+ " " + description);
|
|
|
|
log.println("");
|
|
|
|
log.println("----- Start Table " + tableNumber + " -----");
|
|
|
|
Utility.showSetNames(log, "", set, false, true, Default.ucd);
|
|
|
|
log.println("----- End Table " + tableNumber + " -----");
|
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
public static BitSet guessIDN() {
|
|
|
|
BitSet result = new BitSet();
|
|
|
|
for (int cp = 0; cp < 0x10FFFF; ++cp) {
|
2002-04-23 01:59:16 +00:00
|
|
|
int cat = Default.ucd.getCategory(cp);
|
2001-08-30 20:50:18 +00:00
|
|
|
// 5.1 Currently-prohibited ASCII characters
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
if (cp < 0x80 && cp != '-' && !(cat == Lu || cat == Ll || cat == Nd)) result.set(cp);
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
// 5.2 Space characters
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
if (cat == Zs) result.set(cp);
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
// 5.3 Control characters
|
|
|
|
if (cat == Cc || cat == Zp || cat == Zl) result.set(cp);
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
// exclude those reserved for Cf
|
|
|
|
/*if (0x2060 <= cp && cp <= 0x206F) result.set(cp);
|
|
|
|
if (0xFFF0 <= cp && cp <= 0xFFFC) result.set(cp);
|
|
|
|
if (0xE0000 <= cp && cp <= 0xE0FFF) result.set(cp);
|
|
|
|
*/
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
// 5.4 Private use and replacement characters
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
if (cat == Co) result.set(cp);
|
|
|
|
if (cp == 0xFFFD) result.set(cp);
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
// 5.5 Non-character code points
|
2002-04-23 01:59:16 +00:00
|
|
|
if (Default.ucd.getBinaryProperty(cp, Noncharacter_Code_Point)) result.set(cp);
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
// 5.6 Surrogate codes
|
|
|
|
if (cat == Cs) result.set(cp);
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
// 5.7 Inappropriate for plain text
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
if (cat == Cf) result.set(cp);
|
|
|
|
if (cp == 0xFFFC) result.set(cp);
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
// 5.8 Inappropriate for domain names
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
if (isIDS(cp)) result.set(cp);
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
// 5.9 Change display properties
|
|
|
|
// Cf, checked above
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
// 5.10 Inappropriate characters from common input mechanisms
|
|
|
|
if (cp == 0x3002) result.set(cp);
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
// 5.11 Tagging characters
|
|
|
|
// Cf, checked above
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
static boolean isIDS(int cp) { return 0x2FF0 <= cp && cp <= 0x2FFB; }
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
5.1 Currently-prohibited ASCII characters
|
|
|
|
|
|
|
|
Some of the ASCII characters that are currently prohibited in host names
|
|
|
|
by [STD13] are also used in protocol elements such as URIs [URI]. The other
|
|
|
|
characters in the range U+0000 to U+007F that are not currently allowed
|
|
|
|
are also prohibited in host name parts to reserve them for future use in
|
|
|
|
protocol elements.
|
|
|
|
|
|
|
|
0000-002C; [ASCII CONTROL CHARACTERS and SPACE through ,]
|
|
|
|
002E-002F; [ASCII . through /]
|
|
|
|
003A-0040; [ASCII : through @]
|
|
|
|
005B-0060; [ASCII [ through `]
|
|
|
|
007B-007F; [ASCII { through DEL]
|
|
|
|
|
|
|
|
5.2 Space characters
|
|
|
|
|
|
|
|
Space characters would make visual transcription of URLs nearly
|
|
|
|
impossible and could lead to user entry errors in many ways.
|
|
|
|
|
|
|
|
0020; SPACE
|
|
|
|
00A0; NO-BREAK SPACE
|
|
|
|
1680; OGHAM SPACE MARK
|
|
|
|
2000; EN QUAD
|
|
|
|
2001; EM QUAD
|
|
|
|
2002; EN SPACE
|
|
|
|
2003; EM SPACE
|
|
|
|
2004; THREE-PER-EM SPACE
|
|
|
|
2005; FOUR-PER-EM SPACE
|
|
|
|
2006; SIX-PER-EM SPACE
|
|
|
|
2007; FIGURE SPACE
|
|
|
|
2008; PUNCTUATION SPACE
|
|
|
|
2009; THIN SPACE
|
|
|
|
200A; HAIR SPACE
|
|
|
|
202F; NARROW NO-BREAK SPACE
|
|
|
|
3000; IDEOGRAPHIC SPACE
|
|
|
|
|
|
|
|
5.3 Control characters
|
|
|
|
|
|
|
|
Control characters cannot be seen and can cause unpredictable results
|
|
|
|
when displayed.
|
|
|
|
|
|
|
|
0000-001F; [CONTROL CHARACTERS]
|
|
|
|
007F; DELETE
|
|
|
|
0080-009F; [CONTROL CHARACTERS]
|
|
|
|
2028; LINE SEPARATOR
|
|
|
|
2029; PARAGRAPH SEPARATOR
|
|
|
|
206A-206F; [CONTROL CHARACTERS]
|
|
|
|
FFF9-FFFC; [CONTROL CHARACTERS]
|
|
|
|
1D173-1D17A; [MUSICAL CONTROL CHARACTERS]
|
|
|
|
|
|
|
|
5.4 Private use and replacement characters
|
|
|
|
|
|
|
|
Because private-use characters do not have defined meanings, they are
|
|
|
|
prohibited. The private-use characters are:
|
|
|
|
|
|
|
|
E000-F8FF; [PRIVATE USE, PLANE 0]
|
|
|
|
F0000-FFFFD; [PRIVATE USE, PLANE 15]
|
|
|
|
100000-10FFFD; [PRIVATE USE, PLANE 16]
|
|
|
|
|
|
|
|
The replacement character (U+FFFD) has no known semantic definition in a
|
|
|
|
name, and is often displayed by renderers to indicate "there would be
|
|
|
|
some character here, but it cannot be rendered". For example, on a
|
|
|
|
computer with no Asian fonts, a name with three ideographs might be
|
|
|
|
rendered with three replacement characters.
|
|
|
|
|
|
|
|
FFFD; REPLACEMENT CHARACTER
|
|
|
|
|
|
|
|
5.5 Non-character code points
|
|
|
|
|
|
|
|
Non-character code points are code points that have been allocated in
|
|
|
|
ISO/IEC 10646 but are not characters. Because they are already assigned,
|
|
|
|
they are guaranteed not to later change into characters.
|
|
|
|
|
|
|
|
FDD0-FDEF; [NONCHARACTER CODE POINTS]
|
|
|
|
FFFE-FFFF; [NONCHARACTER CODE POINTS]
|
|
|
|
1FFFE-1FFFF; [NONCHARACTER CODE POINTS]
|
|
|
|
2FFFE-2FFFF; [NONCHARACTER CODE POINTS]
|
|
|
|
3FFFE-3FFFF; [NONCHARACTER CODE POINTS]
|
|
|
|
4FFFE-4FFFF; [NONCHARACTER CODE POINTS]
|
|
|
|
5FFFE-5FFFF; [NONCHARACTER CODE POINTS]
|
|
|
|
6FFFE-6FFFF; [NONCHARACTER CODE POINTS]
|
|
|
|
7FFFE-7FFFF; [NONCHARACTER CODE POINTS]
|
|
|
|
8FFFE-8FFFF; [NONCHARACTER CODE POINTS]
|
|
|
|
9FFFE-9FFFF; [NONCHARACTER CODE POINTS]
|
|
|
|
AFFFE-AFFFF; [NONCHARACTER CODE POINTS]
|
|
|
|
BFFFE-BFFFF; [NONCHARACTER CODE POINTS]
|
|
|
|
CFFFE-CFFFF; [NONCHARACTER CODE POINTS]
|
|
|
|
DFFFE-DFFFF; [NONCHARACTER CODE POINTS]
|
|
|
|
EFFFE-EFFFF; [NONCHARACTER CODE POINTS]
|
|
|
|
FFFFE-FFFFF; [NONCHARACTER CODE POINTS]
|
2002-04-23 01:59:16 +00:00
|
|
|
10FFFE-10FFFF; [NONCHARACTER CODE POINTS]
|
2001-08-30 20:50:18 +00:00
|
|
|
|
|
|
|
5.6 Surrogate codes
|
|
|
|
|
|
|
|
The following code points are permanently reserved for use as surrogate
|
|
|
|
code values in the UTF-16 encoding, will never be assigned to
|
|
|
|
characters, and are therefore prohibited:
|
|
|
|
|
|
|
|
D800-DFFF; [SURROGATE CODES]
|
|
|
|
|
|
|
|
5.7 Inappropriate for plain text
|
|
|
|
|
|
|
|
The following characters should not appear in regular text.
|
|
|
|
|
|
|
|
FFF9; INTERLINEAR ANNOTATION ANCHOR
|
|
|
|
FFFA; INTERLINEAR ANNOTATION SEPARATOR
|
|
|
|
FFFB; INTERLINEAR ANNOTATION TERMINATOR
|
|
|
|
FFFC; OBJECT REPLACEMENT CHARACTER
|
|
|
|
|
|
|
|
5.8 Inappropriate for domain names
|
|
|
|
|
|
|
|
The ideographic description characters allow different sequences of
|
|
|
|
characters to be rendered the same way, which makes them inappropriate
|
|
|
|
for host names that must have a single canonical representation.
|
|
|
|
|
|
|
|
2FF0-2FFB; [IDEOGRAPHIC DESCRIPTION CHARACTERS]
|
|
|
|
|
|
|
|
5.9 Change display properties
|
|
|
|
|
|
|
|
The following characters, some of which are deprecated in ISO/IEC 10646,
|
|
|
|
can cause changes in display or the order in which characters appear
|
|
|
|
when rendered.
|
|
|
|
|
|
|
|
200E; LEFT-TO-RIGHT MARK
|
|
|
|
200F; RIGHT-TO-LEFT MARK
|
|
|
|
202A; LEFT-TO-RIGHT EMBEDDING
|
|
|
|
202B; RIGHT-TO-LEFT EMBEDDING
|
|
|
|
202C; POP DIRECTIONAL FORMATTING
|
|
|
|
202D; LEFT-TO-RIGHT OVERRIDE
|
|
|
|
202E; RIGHT-TO-LEFT OVERRIDE
|
|
|
|
206A; INHIBIT SYMMETRIC SWAPPING
|
|
|
|
206B; ACTIVATE SYMMETRIC SWAPPING
|
|
|
|
206C; INHIBIT ARABIC FORM SHAPING
|
|
|
|
206D; ACTIVATE ARABIC FORM SHAPING
|
|
|
|
206E; NATIONAL DIGIT SHAPES
|
|
|
|
206F; NOMINAL DIGIT SHAPES
|
|
|
|
|
|
|
|
5.10 Inappropriate characters from common input mechanisms
|
|
|
|
|
|
|
|
U+3002 is used as if it were U+002E in many input mechanisms,
|
|
|
|
particularly in Asia. This prohibition allows input mechanisms to safely
|
|
|
|
map U+3002 to U+002E before doing nameprep without worrying about
|
|
|
|
preventing users from accessing legitimate host name parts.
|
|
|
|
|
|
|
|
3002; IDEOGRAPHIC FULL STOP
|
|
|
|
|
|
|
|
5.11 Tagging characters
|
|
|
|
|
|
|
|
The following characters are used for tagging text and are invisible.
|
|
|
|
|
|
|
|
E0001; LANGUAGE TAG
|
|
|
|
E0020-E007F; [TAGGING CHARACTERS]
|
|
|
|
*/
|
2001-08-31 00:30:17 +00:00
|
|
|
|
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
public static int verifyUTFMap(BitSet mappedOut) throws IOException {
|
|
|
|
int errorCount = 0;
|
|
|
|
BufferedReader input = new BufferedReader(new FileReader(IDN_DIR + "IDN-Mapping.txt"),32*1024);
|
|
|
|
String line = "";
|
|
|
|
Map idnFold = new TreeMap();
|
|
|
|
Map idnWhy = new HashMap();
|
|
|
|
try {
|
|
|
|
String[] parts = new String[20];
|
|
|
|
for (int lineNumber = 1; ; ++lineNumber) {
|
|
|
|
line = input.readLine();
|
|
|
|
if (line == null) break;
|
|
|
|
if ((lineNumber % 500) == 0) {
|
|
|
|
Utility.fixDot();
|
|
|
|
System.out.println("//" + lineNumber + ": '" + line + "'");
|
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
if (line.length() == 0) continue;
|
2002-06-22 01:21:11 +00:00
|
|
|
if (line.charAt(0) == '-') continue;
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
int count = Utility.split(line,';',parts);
|
2002-06-22 01:21:11 +00:00
|
|
|
if (count != 3) throw new ChainException("Incorrect # of fields in IDN folding, line = {0}",
|
|
|
|
new String[] {line});
|
2001-08-30 20:50:18 +00:00
|
|
|
|
|
|
|
String key = Utility.fromHex(parts[0]);
|
|
|
|
if (UTF32.length32(key) != 1) throw new ChainException("First IDN field not single character: " + line, null);
|
|
|
|
int cp = UTF32.char32At(key, 0);
|
2002-04-23 01:59:16 +00:00
|
|
|
if (!Default.ucd.isAssigned(cp) || Default.ucd.isPUA(cp)) throw new ChainException("IDN character unassigned or PUA: " + line, null);
|
2001-08-30 20:50:18 +00:00
|
|
|
String value = Utility.fromHex(parts[1]);
|
|
|
|
String reason = parts[2].trim();
|
|
|
|
|
|
|
|
if (reason.equals("Map out")) {
|
|
|
|
value = Utility.fromHex(parts[1]);
|
|
|
|
Utility.fixDot();
|
2001-09-19 23:33:52 +00:00
|
|
|
showError("Mapping Out: ", cp, "");
|
2001-08-30 20:50:18 +00:00
|
|
|
mappedOut.set(cp);
|
|
|
|
}
|
|
|
|
idnFold.put(key, value);
|
|
|
|
idnWhy.put(key, reason);
|
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
for (int cp = 0; cp <= 0x10FFFF; ++cp) {
|
|
|
|
Utility.dot(cp);
|
2002-04-23 01:59:16 +00:00
|
|
|
if (!Default.ucd.isAssigned(cp) || Default.ucd.isPUA(cp)) continue;
|
2001-08-30 20:50:18 +00:00
|
|
|
if (mappedOut.get(cp)) continue;
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
String key = UTF32.valueOf32(cp);
|
|
|
|
String value = (String)idnFold.get(key);
|
|
|
|
if (value == null) value = key;
|
|
|
|
String reason = (String)idnWhy.get(key);
|
2002-04-23 01:59:16 +00:00
|
|
|
String ucdFold = Default.ucd.getCase(cp, FULL, FOLD, "I");
|
2001-08-30 20:50:18 +00:00
|
|
|
if (!ucdFold.equals(value)) {
|
2002-04-23 01:59:16 +00:00
|
|
|
String b = Default.nfkc.normalize(Default.ucd.getCase(cp, FULL, FOLD, "I"));
|
|
|
|
String c = Default.nfkc.normalize(Default.ucd.getCase(b, FULL, FOLD, "I"));
|
2001-08-30 20:50:18 +00:00
|
|
|
|
|
|
|
if (c.equals(value)) continue;
|
|
|
|
Utility.fixDot();
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
System.out.println("Mismatch: " + Default.ucd.getCodeAndName(cp));
|
|
|
|
System.out.println(" UCD Case Fold: <" + Default.ucd.getCodeAndName(ucdFold) + ">");
|
|
|
|
System.out.println(" IDN Map [" + reason + "]: <" + Default.ucd.getCodeAndName(value) + ">");
|
2001-08-30 20:50:18 +00:00
|
|
|
errorCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
input.close();
|
|
|
|
}
|
|
|
|
return errorCount;
|
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
static BitSet getIDNList(String file) throws IOException {
|
|
|
|
BufferedReader input = new BufferedReader(new FileReader(IDN_DIR + file),32*1024);
|
|
|
|
BitSet result = new BitSet();
|
|
|
|
String line;
|
|
|
|
try {
|
|
|
|
String[] parts = new String[20];
|
|
|
|
for (int lineNumber = 1; ; ++lineNumber) {
|
|
|
|
line = input.readLine();
|
|
|
|
if (line == null) break;
|
|
|
|
if ((lineNumber % 500) == 0) {
|
|
|
|
Utility.fixDot();
|
|
|
|
System.out.println("//" + lineNumber + ": '" + line + "'");
|
|
|
|
}
|
2002-06-22 01:21:11 +00:00
|
|
|
|
|
|
|
int commentPos = line.indexOf(';');
|
|
|
|
if (commentPos >= 0) line = line.substring(0,commentPos);
|
|
|
|
line = line.trim();
|
2001-08-30 20:50:18 +00:00
|
|
|
if (line.length() == 0) continue;
|
2002-06-22 01:21:11 +00:00
|
|
|
if (line.charAt(0) == '-') continue;
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
int count = Utility.split(line,'-',parts);
|
|
|
|
if (count > 2) throw new ChainException("Incorrect # of fields in IDN list", null);
|
|
|
|
int start = Utility.codePointFromHex(parts[0]);
|
|
|
|
int end = count == 1 ? start : Utility.codePointFromHex(parts[1]);
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
for (int i = start; i <= end; ++i) {
|
|
|
|
result.set(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
input.close();
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2002-03-20 00:21:43 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
+ "\r\n# Generated from <2060..206F, FFF0..FFFB, E0000..E0FFF>"
|
|
|
|
+ "\r\n# + Other_Default_Ignorable_Code_Point + (Cf + Cc + Cs - White_Space)";
|
|
|
|
*/
|
|
|
|
|
|
|
|
public static void diffIgnorable () {
|
2002-04-23 01:59:16 +00:00
|
|
|
Default.setUCD();
|
2002-03-20 00:21:43 +00:00
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
UnicodeSet control = UnifiedBinaryProperty.make(CATEGORY + Cf, Default.ucd).getSet();
|
2002-03-20 00:21:43 +00:00
|
|
|
|
|
|
|
System.out.println("Cf");
|
2002-04-23 01:59:16 +00:00
|
|
|
Utility.showSetNames("", control, false, Default.ucd);
|
2002-03-20 00:21:43 +00:00
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
control.addAll(UnifiedBinaryProperty.make(CATEGORY + Cc, Default.ucd).getSet());
|
2002-03-20 00:21:43 +00:00
|
|
|
|
|
|
|
System.out.println("Cf + Cc");
|
2002-04-23 01:59:16 +00:00
|
|
|
Utility.showSetNames("", control, false, Default.ucd);
|
2002-03-20 00:21:43 +00:00
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
control.addAll(UnifiedBinaryProperty.make(CATEGORY + Cs, Default.ucd).getSet());
|
2002-03-20 00:21:43 +00:00
|
|
|
|
|
|
|
System.out.println("Cf + Cc + Cs");
|
2002-04-23 01:59:16 +00:00
|
|
|
Utility.showSetNames("", control, false, Default.ucd);
|
2002-03-20 00:21:43 +00:00
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
control.removeAll(UnifiedBinaryProperty.make(BINARY_PROPERTIES + White_space, Default.ucd).getSet());
|
2002-03-20 00:21:43 +00:00
|
|
|
|
|
|
|
System.out.println("Cf + Cc + Cs - WhiteSpace");
|
2002-04-23 01:59:16 +00:00
|
|
|
Utility.showSetNames("", control, false, Default.ucd);
|
2002-03-20 00:21:43 +00:00
|
|
|
|
|
|
|
control.add(0x2060,0x206f).add(0xFFF0,0xFFFB).add(0xE0000,0xE0FFF);
|
|
|
|
|
|
|
|
System.out.println("(Cf + Cc + Cs - WhiteSpace) + ranges");
|
2002-04-23 01:59:16 +00:00
|
|
|
Utility.showSetNames("", control, false, Default.ucd);
|
2002-03-20 00:21:43 +00:00
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
UnicodeSet odicp = UnifiedBinaryProperty.make(BINARY_PROPERTIES + Other_Default_Ignorable_Code_Point, Default.ucd).getSet();
|
2002-03-20 00:21:43 +00:00
|
|
|
|
|
|
|
odicp.removeAll(control);
|
|
|
|
|
|
|
|
System.out.println("Minimal Default Ignorable Code Points");
|
2002-04-23 01:59:16 +00:00
|
|
|
Utility.showSetNames("", odicp, true, Default.ucd);
|
2002-03-20 00:21:43 +00:00
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
|
|
|
|
2001-09-01 00:06:48 +00:00
|
|
|
public static void IdentifierTest() {
|
2001-08-30 20:50:18 +00:00
|
|
|
String x = normalize(UTF32.valueOf32(0x10300), 4) ;
|
|
|
|
getCategoryID(x);
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
/*
|
|
|
|
Changes Category: U+10300 OLD ITALIC LETTER A
|
|
|
|
nfx_cp: U+D800 <surrogate-D800>
|
|
|
|
isIdentifier(nfx_cp, true): false
|
|
|
|
cat(nfx_cp): Cs
|
|
|
|
isIdentifierStart(cp, true): true
|
|
|
|
cat(cp): Lo
|
|
|
|
*/
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
for (int j = 0; j < 5; ++j) {
|
|
|
|
System.out.println();
|
|
|
|
System.out.println("Testing Identifier Closure for " + NAMES[j]);
|
|
|
|
System.out.println();
|
|
|
|
for (int cp = 0; cp < 0x10FFFF; ++cp) {
|
|
|
|
Utility.dot(cp);
|
2002-04-23 01:59:16 +00:00
|
|
|
if (!Default.ucd.isAssigned(cp)) continue;
|
|
|
|
if (Default.ucd.isPUA(cp)) continue;
|
2002-05-31 01:41:04 +00:00
|
|
|
if (isNormalized(cp, j)) continue;
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
if (cp == 0xFDFB || cp == 0x0140) {
|
|
|
|
System.out.println("debug point");
|
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
boolean norm;
|
|
|
|
boolean plain;
|
|
|
|
|
|
|
|
String x_cp = 'x' + UTF32.valueOf32(cp);
|
|
|
|
String nfx_x_cp = normalize(x_cp, j);
|
2003-02-25 23:38:23 +00:00
|
|
|
if (true) {
|
|
|
|
throw new RuntimeException("Fix plain & norm, 4 instances!!");
|
|
|
|
}
|
|
|
|
// plain = Default.ucd.isIdentifier(x_cp, true);
|
|
|
|
//norm = Default.ucd.isIdentifier(nfx_x_cp, true);
|
2001-08-30 20:50:18 +00:00
|
|
|
if (plain & !norm) {
|
|
|
|
Utility.fixDot();
|
2002-04-23 01:59:16 +00:00
|
|
|
System.out.println("*Not Identifier: " + Default.ucd.getCodeAndName(cp));
|
|
|
|
System.out.println(" nfx_x_cp: " + Default.ucd.getCodeAndName(nfx_x_cp));
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
System.out.println(" isIdentifier(nfx_x_cp, true): " + norm);
|
|
|
|
System.out.println(" cat(nfx_x_cp): " + getCategoryID(nfx_x_cp));
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
System.out.println(" isIdentifier(x_cp, true): " + plain);
|
|
|
|
System.out.println(" cat(x_cp): " + getCategoryID(x_cp));
|
|
|
|
continue;
|
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
String nfx_cp = normalize(UTF32.valueOf32(cp), j);
|
2003-02-25 23:38:23 +00:00
|
|
|
// plain = Default.ucd.isIdentifierStart(cp, true);
|
|
|
|
// norm = Default.ucd.isIdentifier(nfx_cp, true);
|
2001-08-30 20:50:18 +00:00
|
|
|
if (plain & !norm) {
|
|
|
|
Utility.fixDot();
|
2002-04-23 01:59:16 +00:00
|
|
|
System.out.println(" Changes Category: " + Default.ucd.getCodeAndName(cp));
|
|
|
|
System.out.println(" nfx_cp: " + Default.ucd.getCodeAndName(nfx_cp));
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
System.out.println(" isIdentifier(nfx_cp, true): " + norm);
|
|
|
|
System.out.println(" cat(nfx_cp): " + getCategoryID(nfx_cp));
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
System.out.println(" isIdentifierStart(cp, true): " + plain);
|
2002-04-23 01:59:16 +00:00
|
|
|
System.out.println(" cat(cp): " + Default.ucd.getCategoryID(cp));
|
2001-08-30 20:50:18 +00:00
|
|
|
System.out.println();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
static String getCategoryID(String s) {
|
2002-04-23 01:59:16 +00:00
|
|
|
if (UTF32.length32(s) == 1) return Default.ucd.getCategoryID(UTF32.char32At(s, 0));
|
2001-08-30 20:50:18 +00:00
|
|
|
StringBuffer result = new StringBuffer();
|
|
|
|
int cp;
|
|
|
|
for (int i = 0; i < s.length(); i += UTF32.count16(cp)) {
|
|
|
|
cp = UTF32.char32At(s, i);
|
|
|
|
if (i != 0) result.append(' ');
|
2002-04-23 01:59:16 +00:00
|
|
|
result.append(Default.ucd.getCategoryID(cp));
|
2001-08-30 20:50:18 +00:00
|
|
|
}
|
|
|
|
return result.toString();
|
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
static String normalize(String s, int j) {
|
2002-04-23 01:59:16 +00:00
|
|
|
if (j < 4) return Default.nf[j].normalize(s);
|
|
|
|
return Default.ucd.getCase(s, FULL, FOLD);
|
2001-08-30 20:50:18 +00:00
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2002-05-31 01:41:04 +00:00
|
|
|
static boolean isNormalized(int cp, int j) {
|
|
|
|
if (j < 4) return !Default.nf[j].isNormalized(cp);
|
|
|
|
return false;
|
2001-08-30 20:50:18 +00:00
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
private static final String[] NAMES = {"Default.nfd", "NFC", "NFKD", "NFKC", "Fold"};
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-09-01 00:06:48 +00:00
|
|
|
public static void NFTest() {
|
2001-08-30 20:50:18 +00:00
|
|
|
for (int j = 0; j < 4; ++j) {
|
2002-04-23 01:59:16 +00:00
|
|
|
Normalizer nfx = Default.nf[j];
|
2001-08-30 20:50:18 +00:00
|
|
|
System.out.println();
|
2002-05-31 01:41:04 +00:00
|
|
|
System.out.println("Testing isNormalized for " + NAMES[j]);
|
2001-08-30 20:50:18 +00:00
|
|
|
System.out.println();
|
|
|
|
for (int i = 0; i < 0x10FFFF; ++i) {
|
|
|
|
Utility.dot(i);
|
2002-04-23 01:59:16 +00:00
|
|
|
if (!Default.ucd.isAssigned(i)) continue;
|
|
|
|
if (Default.ucd.isPUA(i)) continue;
|
2001-08-30 20:50:18 +00:00
|
|
|
String s = nfx.normalize(i);
|
|
|
|
boolean differs = !s.equals(UTF32.valueOf32(i));
|
2002-05-31 01:41:04 +00:00
|
|
|
boolean call = !nfx.isNormalized(i);
|
2001-08-30 20:50:18 +00:00
|
|
|
if (differs != call) {
|
|
|
|
Utility.fixDot();
|
|
|
|
System.out.println("Problem: differs: " + differs
|
2002-04-23 01:59:16 +00:00
|
|
|
+ ", call: " + call + " " + Default.ucd.getCodeAndName(i));
|
2001-08-30 20:50:18 +00:00
|
|
|
}
|
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
}
|
|
|
|
}
|
2002-03-15 00:34:46 +00:00
|
|
|
|
|
|
|
static final int EXCEPTION_FLAG = 0x8000000;
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2002-03-15 00:34:46 +00:00
|
|
|
public static void checkScripts() throws IOException {
|
2002-04-23 01:59:16 +00:00
|
|
|
Default.setUCD();
|
2002-03-15 00:34:46 +00:00
|
|
|
boolean ok;
|
|
|
|
Map m = new TreeMap();
|
|
|
|
UnicodeSet exceptions = ScriptExceptions.getExceptions();
|
|
|
|
int maxScriptLen = 0;
|
|
|
|
UnicodeSet show = new UnicodeSet();
|
|
|
|
show.add(0x2071);
|
|
|
|
show.add(0x207F);
|
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
for (int i = 0; i < 0x10FFFF; ++i) {
|
2002-04-23 01:59:16 +00:00
|
|
|
if (!Default.ucd.isAssigned(i)) continue;
|
|
|
|
byte cat = Default.ucd.getCategory(i);
|
|
|
|
byte script = Default.ucd.getScript(i);
|
2002-03-15 00:34:46 +00:00
|
|
|
switch (cat) {
|
|
|
|
case Lo: case Lt: case Ll: case Lu: case Lm: case Mc: case Sk:
|
|
|
|
ok = script != INHERITED_SCRIPT && script != COMMON_SCRIPT;
|
|
|
|
break;
|
|
|
|
case Mn: case Me:
|
|
|
|
ok = script == INHERITED_SCRIPT;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ok = script == COMMON_SCRIPT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (show.contains(i)) {
|
2002-04-23 01:59:16 +00:00
|
|
|
System.out.println(Default.ucd.getCodeAndName(i)
|
|
|
|
+ "; " + Default.ucd.getScriptID(i)
|
|
|
|
+ "; " + Default.ucd.getCategoryID(i)
|
2002-03-15 00:34:46 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
if (!ok) {
|
|
|
|
if (cat == Ll || cat == Lt) cat = Lu;
|
|
|
|
int intKey = (cat << 8) + script;
|
|
|
|
if (exceptions.contains(i)) intKey |= EXCEPTION_FLAG;
|
|
|
|
Integer key = new Integer(intKey);
|
|
|
|
UnicodeSet us = (UnicodeSet) m.get(key);
|
|
|
|
if (us == null) {
|
|
|
|
us = new UnicodeSet();
|
|
|
|
m.put(key, us);
|
|
|
|
}
|
|
|
|
us.add(i);
|
2002-04-23 01:59:16 +00:00
|
|
|
int len = Default.ucd.getScriptID(i).length();
|
2002-03-15 00:34:46 +00:00
|
|
|
if (maxScriptLen < len) maxScriptLen = len;
|
2001-08-30 20:50:18 +00:00
|
|
|
}
|
|
|
|
}
|
2002-03-15 00:34:46 +00:00
|
|
|
|
2002-07-30 09:57:18 +00:00
|
|
|
PrintWriter log = Utility.openPrintWriter("CheckScriptsLog.txt", Utility.LATIN1_UNIX);
|
2002-03-15 00:34:46 +00:00
|
|
|
|
|
|
|
Iterator it = m.keySet().iterator();
|
|
|
|
while (it.hasNext()) {
|
|
|
|
Integer key = (Integer) it.next();
|
|
|
|
int intKey = key.intValue();
|
|
|
|
UnicodeSet badChars = (UnicodeSet) m.get(key);
|
|
|
|
int ranges = badChars.getRangeCount();
|
|
|
|
for (int kk = 0; kk < ranges; ++kk) {
|
|
|
|
int start = badChars.getRangeStart(kk);
|
|
|
|
int end = badChars.getRangeEnd(kk);
|
|
|
|
String code = Utility.hex(start) + (start != end ? ".." + Utility.hex(end) : "");
|
2002-04-23 01:59:16 +00:00
|
|
|
String scriptName = Default.ucd.getScriptID(start);
|
2002-03-15 00:34:46 +00:00
|
|
|
String title = "FAIL";
|
|
|
|
if ((intKey & EXCEPTION_FLAG) != 0) title = "EXCEPTION";
|
|
|
|
log.println(title + ": " + code + "; " + Utility.repeat(" ", 14 - code.length())
|
|
|
|
+ scriptName + Utility.repeat(" ", maxScriptLen-scriptName.length())
|
2002-04-23 01:59:16 +00:00
|
|
|
+ " # (" + LCgetCategoryID(start) + ") " + Default.ucd.getName(start)
|
|
|
|
+ (start != end ? ".." + Default.ucd.getName(end) : "")
|
2002-03-15 00:34:46 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
log.println();
|
|
|
|
}
|
|
|
|
log.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
static public String LCgetCategoryID(int cp) {
|
2002-04-23 01:59:16 +00:00
|
|
|
byte cat = Default.ucd.getCategory(cp);
|
2002-03-15 00:34:46 +00:00
|
|
|
if (cat == Lu || cat == Lt || cat == Ll) return "LC";
|
2002-04-23 01:59:16 +00:00
|
|
|
return Default.ucd.getCategoryID(cp);
|
2001-08-30 20:50:18 +00:00
|
|
|
}
|
2002-03-20 00:21:43 +00:00
|
|
|
|
|
|
|
static public void verifyNormalizationStability() {
|
2002-04-23 01:59:16 +00:00
|
|
|
Default.setUCD();
|
2002-03-20 00:21:43 +00:00
|
|
|
verifyNormalizationStability2("3.1.0");
|
|
|
|
verifyNormalizationStability2("3.0.0");
|
|
|
|
}
|
|
|
|
|
|
|
|
static public void verifyNormalizationStability2(String version) {
|
|
|
|
|
2002-05-31 01:41:04 +00:00
|
|
|
// Default.nfd.normalizationDiffers(0x10300);
|
2002-03-20 00:21:43 +00:00
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
UCD older = UCD.make(version); // Default.ucd.getPreviousVersion();
|
2002-03-20 00:21:43 +00:00
|
|
|
|
|
|
|
Normalizer oldNFC = new Normalizer(Normalizer.NFC, older.getVersion());
|
|
|
|
Normalizer oldNFD = new Normalizer(Normalizer.NFD, older.getVersion());
|
|
|
|
Normalizer oldNFKC = new Normalizer(Normalizer.NFKC, older.getVersion());
|
|
|
|
Normalizer oldNFKD = new Normalizer(Normalizer.NFKD, older.getVersion());
|
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
System.out.println("Testing " + Default.nfd.getUCDVersion() + " against " + oldNFD.getUCDVersion());
|
2002-03-20 00:21:43 +00:00
|
|
|
|
|
|
|
for (int i = 0; i <= 0x10FFFF; ++i) {
|
|
|
|
Utility.dot(i);
|
2002-04-23 01:59:16 +00:00
|
|
|
if (!Default.ucd.isAssigned(i)) continue;
|
|
|
|
byte cat = Default.ucd.getCategory(i);
|
2002-03-20 00:21:43 +00:00
|
|
|
if (cat == Cs || cat == PRIVATE_USE) continue;
|
|
|
|
|
|
|
|
if (i == 0x5e) {
|
|
|
|
System.out.println("debug");
|
2002-04-23 01:59:16 +00:00
|
|
|
String test1 = Default.nfkd.normalize(i);
|
2002-03-20 00:21:43 +00:00
|
|
|
String test2 = oldNFKD.normalize(i);
|
2002-04-23 01:59:16 +00:00
|
|
|
System.out.println("Testing (new/old)" + Default.ucd.getCodeAndName(i));
|
|
|
|
System.out.println("\t" + Default.ucd.getCodeAndName(test1));
|
|
|
|
System.out.println("\t" + Default.ucd.getCodeAndName(test2));
|
2002-03-20 00:21:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (older.isAssigned(i)) {
|
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
int newCan = Default.ucd.getCombiningClass(i);
|
2002-03-20 00:21:43 +00:00
|
|
|
int oldCan = older.getCombiningClass(i);
|
|
|
|
if (newCan != oldCan) {
|
|
|
|
System.out.println("FAILS CCC STABILITY: " + newCan + " != " + oldCan
|
2002-04-23 01:59:16 +00:00
|
|
|
+ "; " + Default.ucd.getCodeAndName(i));
|
2002-03-20 00:21:43 +00:00
|
|
|
}
|
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
verifyEquals(i, "NFD STABILITY (new/old)", Default.nfd.normalize(i), oldNFD.normalize(i));
|
|
|
|
verifyEquals(i, "NFC STABILITY (new/old)", Default.nfc.normalize(i), oldNFC.normalize(i));
|
|
|
|
verifyEquals(i, "NFKD STABILITY (new/old)", Default.nfkd.normalize(i), oldNFKD.normalize(i));
|
|
|
|
verifyEquals(i, "NFKC STABILITY (new/old)", Default.nfkc.normalize(i), oldNFKC.normalize(i));
|
2002-03-20 00:21:43 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
// not in older version.
|
|
|
|
// (1) If there is a decomp, and it is composed of all OLD characters, then it must NOT compose
|
2002-05-31 01:41:04 +00:00
|
|
|
if (!Default.nfd.isNormalized(i)) {
|
2002-04-23 01:59:16 +00:00
|
|
|
String decomp = Default.nfd.normalize(i);
|
2002-03-20 00:21:43 +00:00
|
|
|
if (noneHaveCategory(decomp, Cn, older)) {
|
2002-04-23 01:59:16 +00:00
|
|
|
String recomp = Default.nfc.normalize(decomp);
|
2002-03-20 00:21:43 +00:00
|
|
|
if (recomp.equals(UTF16.valueOf(i))) {
|
|
|
|
Utility.fixDot();
|
2002-04-23 01:59:16 +00:00
|
|
|
System.out.println("FAILS COMP STABILITY: " + Default.ucd.getCodeAndName(i));
|
|
|
|
System.out.println("\t" + Default.ucd.getCodeAndName(decomp));
|
|
|
|
System.out.println("\t" + Default.ucd.getCodeAndName(recomp));
|
2002-03-20 00:21:43 +00:00
|
|
|
System.out.println();
|
|
|
|
throw new IllegalArgumentException("Comp stability");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean noneHaveCategory(String s, byte cat, UCD ucd) {
|
|
|
|
int cp;
|
|
|
|
for (int i = 0; i < s.length(); i += UTF16.getCharCount(cp)) {
|
|
|
|
cp = UTF16.charAt(s, i);
|
|
|
|
byte cat2 = ucd.getCategory(i);
|
|
|
|
if (cat == cat2) return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void verifyEquals(int cp, String message, String a, String b) {
|
|
|
|
if (!a.equals(b)) {
|
|
|
|
Utility.fixDot();
|
2002-04-23 01:59:16 +00:00
|
|
|
System.out.println("FAILS " + message + ": " + Default.ucd.getCodeAndName(cp));
|
|
|
|
System.out.println("\t" + Default.ucd.getCodeAndName(a));
|
|
|
|
System.out.println("\t" + Default.ucd.getCodeAndName(b));
|
2002-03-20 00:21:43 +00:00
|
|
|
System.out.println();
|
|
|
|
}
|
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
public static void checkAgainstUInfo() {
|
|
|
|
/*
|
2002-04-23 01:59:16 +00:00
|
|
|
Default.ucd = UCD.make(Default.Default.ucdVersion);
|
2001-08-30 20:50:18 +00:00
|
|
|
UData x = new UData();
|
|
|
|
x.fleshOut();
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
System.out.println(Default.ucd.toString(0x1E0A));
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
UInfo.init();
|
|
|
|
System.out.println("Cross-checking against old implementation");
|
2002-04-23 01:59:16 +00:00
|
|
|
System.out.println("Version: " + Default.ucd.getVersion() + ", " + new Date(Default.ucd.getDate()));
|
2001-08-30 20:50:18 +00:00
|
|
|
for (int i = 0; i <= 0xFFFF; ++i) {
|
|
|
|
Utility.dot(i);
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
if ((i & 0x0FFF) == 0) System.out.println("#" + Utility.hex(i));
|
|
|
|
try {
|
2002-04-23 01:59:16 +00:00
|
|
|
check(i, Default.ucd.getName(i), UInfo.getName((char)i), "Name");
|
|
|
|
check(i, Default.ucd.getCategory(i), UInfo.getCategory((char)i), UCD_Names.GC, "GeneralCategory");
|
|
|
|
check(i, Default.ucd.getCombiningClass(i), UInfo.getCanonicalClass((char)i), "CanonicalClass");
|
|
|
|
check(i, Default.ucd.getBidiClass(i), UInfo.getBidiClass((char)i), UCD_Names.BC, "BidiClass");
|
|
|
|
check(i, Default.ucd.getDecompositionMapping(i), UInfo.getDecomposition((char)i), "Decomposition");
|
|
|
|
check(i, Default.ucd.getDecompositionType(i), UInfo.getDecompositionType((char)i), UCD_Names.DT, "DecompositionType");
|
|
|
|
check(i, Default.ucd.getNumericValue(i), UInfo.getNumeric((char)i), "NumericValue");
|
|
|
|
check(i, Default.ucd.getNumericType(i), UInfo.getNumericType((char)i), UCD_Names.NT, "NumericType");
|
|
|
|
|
|
|
|
check(i, Default.ucd.getCase(i, SIMPLE, LOWER), UInfo.getLowercase((char)i), "SimpleLowercase");
|
|
|
|
check(i, Default.ucd.getCase(i, SIMPLE, UPPER), UInfo.getUppercase((char)i), "SimpleUppercase");
|
|
|
|
check(i, Default.ucd.getCase(i, SIMPLE, TITLE), UInfo.getTitlecase((char)i), "SimpleTitlecase");
|
|
|
|
//check(i, Default.ucd.getSimpleCaseFolding(i), UInfo.getSimpleCaseFolding((char)i));
|
|
|
|
|
|
|
|
if (Default.ucd.getSpecialCase(i).length() == 0) { // NORMAL
|
|
|
|
check(i, Default.ucd.getCase(i, FULL, LOWER), UInfo.toLowercase((char)i, ""), "FullLowercase");
|
|
|
|
check(i, Default.ucd.getCase(i, FULL, UPPER), UInfo.toUppercase((char)i, ""), "FullUppercase");
|
|
|
|
check(i, Default.ucd.getCase(i, FULL, TITLE), UInfo.toTitlecase((char)i, ""), "FullTitlecase");
|
2001-08-30 20:50:18 +00:00
|
|
|
} else { // SPECIAL
|
2002-04-23 01:59:16 +00:00
|
|
|
check(i, Default.ucd.getCase(i, SIMPLE, LOWER), UInfo.toLowercase((char)i, ""), "FullLowercase");
|
|
|
|
check(i, Default.ucd.getCase(i, SIMPLE, UPPER), UInfo.toUppercase((char)i, ""), "FullUppercase");
|
|
|
|
check(i, Default.ucd.getCase(i, SIMPLE, TITLE), UInfo.toTitlecase((char)i, ""), "FullTitlecase");
|
2001-08-30 20:50:18 +00:00
|
|
|
}
|
2002-04-23 01:59:16 +00:00
|
|
|
// check(i, Default.ucd.getFullCaseFolding(i), UInfo.getFullCaseFolding((char)i));
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
check(i, Default.ucd.getSpecialCase(i).toUpperCase(), UInfo.getCaseCondition((char)i).toUpperCase(), "SpecialCase");
|
|
|
|
check(i, Default.ucd.getLineBreak(i), UInfo.getLineBreakType((char)i), UCD_Names.LB, "LineBreak");
|
|
|
|
check(i, Default.ucd.getEastAsianWidth(i), UInfo.getEastAsianWidthType((char)i), UCD_Names.EA, "EastAsian");
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
int props = Default.ucd.getBinaryProperties(i);
|
2001-08-30 20:50:18 +00:00
|
|
|
check(i, (props>>BidiMirrored) & 1, UInfo.getMirrored((char)i), UCD_Names.YN_TABLE, "BidiMirroring");
|
|
|
|
check(i, (props>>CompositionExclusion) & 1, UInfo.isCompositionExcluded((char)i)?1:0, UCD_Names.YN_TABLE, "Comp-Exclusion");
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
} catch (Exception e) {
|
|
|
|
Utility.fixDot();
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
System.out.println("Error: " + Utility.hex(i) + " " + e.getClass().getName() + e.getMessage());
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
public static void check(int cp, boolean x, boolean y, String[] names, String type) {
|
|
|
|
check(cp, x ? 1 : 0, y ? 1 : 0, names, type);
|
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
public static void check(int cp, int x, int y, String[] names, String type) {
|
|
|
|
if (x == y) return;
|
|
|
|
showLast(cp);
|
|
|
|
Utility.fixDot();
|
2001-08-31 00:30:17 +00:00
|
|
|
System.out.println(" " + type + ": "
|
|
|
|
+ Utility.getName(x, names) + " (" + x + ") " + " != "
|
2001-08-30 20:50:18 +00:00
|
|
|
+ Utility.getName(y, names) + " (" + y + ") ") ;
|
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
public static void check(int cp, int x, int y, String type) {
|
|
|
|
if (x == y) return;
|
|
|
|
showLast(cp);
|
|
|
|
Utility.fixDot();
|
|
|
|
System.out.println(" " + type + ": " + x + " != " + y) ;
|
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2003-03-12 16:01:26 +00:00
|
|
|
public static void check(int cp, double x, double y, String type) {
|
2001-08-30 20:50:18 +00:00
|
|
|
if (!(x > y) && !(x < y)) return; // funny syntax to catch NaN
|
|
|
|
showLast(cp);
|
|
|
|
Utility.fixDot();
|
|
|
|
System.out.println(" " + type + ": " + x + " != " + y) ;
|
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
public static void check(int cp, String x, String y, String type) {
|
|
|
|
if (x != null && x.equals(y)) return;
|
2001-08-31 00:30:17 +00:00
|
|
|
if (x != null && y != null
|
|
|
|
&& x.length() > 0 && y.length() > 0
|
2001-08-30 20:50:18 +00:00
|
|
|
&& x.charAt(0) == '<' && y.charAt(0) == '<') {
|
|
|
|
if (x.startsWith("<unassigned") && y.equals("<reserved>")) return;
|
|
|
|
if (y.equals("<control>")) return;
|
|
|
|
if (x.startsWith("<surrogate") && y.indexOf("Surrogate") != -1) return;
|
|
|
|
if (x.startsWith("<private use") && y.startsWith("<Private Use")) return;
|
|
|
|
}
|
|
|
|
showLast(cp);
|
|
|
|
Utility.fixDot();
|
|
|
|
System.out.println(" " + type + ": " + Utility.quoteJavaString(x) + " != " + Utility.quoteJavaString(y));
|
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
|
|
|
|
static int lastShowed = -1;
|
|
|
|
static boolean showCanonicalDecomposition = false;
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
static void showLast(int cp) {
|
|
|
|
if (lastShowed != cp) {
|
|
|
|
Utility.fixDot();
|
|
|
|
System.out.println();
|
2002-04-23 01:59:16 +00:00
|
|
|
String s = Default.ucd.getDecompositionMapping(cp);
|
|
|
|
System.out.print(Default.ucd.getCodeAndName(cp));
|
2001-08-30 20:50:18 +00:00
|
|
|
if (showCanonicalDecomposition && !s.equals(UTF32.valueOf32(cp))) {
|
2002-04-23 01:59:16 +00:00
|
|
|
System.out.print(" => " + Default.ucd.getCodeAndName(s));
|
2001-08-30 20:50:18 +00:00
|
|
|
}
|
|
|
|
System.out.println();
|
|
|
|
lastShowed = cp;
|
|
|
|
}
|
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
public static void test1() {
|
2002-04-23 01:59:16 +00:00
|
|
|
Default.setUCD();
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
for (int i = 0x19; i < 0x10FFFF; ++i) {
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
System.out.println(Utility.hex(i) + " " + Utility.quoteJavaString(Default.ucd.getName(i)));
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
System.out.print(" "
|
2002-04-23 01:59:16 +00:00
|
|
|
+ ", gc=" + Default.ucd.getCategoryID(i)
|
|
|
|
+ ", bc=" + Default.ucd.getBidiClassID(i)
|
|
|
|
+ ", cc=" + Default.ucd.getCombiningClassID(i)
|
|
|
|
+ ", ea=" + Default.ucd.getEastAsianWidthID(i)
|
|
|
|
+ ", lb=" + Default.ucd.getLineBreakID(i)
|
|
|
|
+ ", dt=" + Default.ucd.getDecompositionTypeID(i)
|
|
|
|
+ ", nt=" + Default.ucd.getNumericTypeID(i)
|
|
|
|
+ ", nv=" + Default.ucd.getNumericValue(i)
|
2001-08-30 20:50:18 +00:00
|
|
|
);
|
|
|
|
for (int j = 0; j < UCD_Types.LIMIT_BINARY_PROPERTIES; ++j) {
|
2002-04-23 01:59:16 +00:00
|
|
|
if (Default.ucd.getBinaryProperty(i,j)) System.out.print(", " + UCD_Names.BP[j]);
|
2001-08-30 20:50:18 +00:00
|
|
|
}
|
|
|
|
System.out.println();
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
System.out.println(" "
|
2002-04-23 01:59:16 +00:00
|
|
|
+ ", dm=" + Utility.quoteJavaString(Default.ucd.getDecompositionMapping(i))
|
|
|
|
+ ", slc=" + Utility.quoteJavaString(Default.ucd.getCase(i, SIMPLE, LOWER))
|
|
|
|
+ ", stc=" + Utility.quoteJavaString(Default.ucd.getCase(i, SIMPLE, TITLE))
|
|
|
|
+ ", suc=" + Utility.quoteJavaString(Default.ucd.getCase(i, SIMPLE, UPPER))
|
|
|
|
+ ", flc=" + Utility.quoteJavaString(Default.ucd.getCase(i, FULL, LOWER))
|
|
|
|
+ ", ftc=" + Utility.quoteJavaString(Default.ucd.getCase(i, FULL, TITLE))
|
|
|
|
+ ", fuc=" + Utility.quoteJavaString(Default.ucd.getCase(i, FULL, UPPER))
|
|
|
|
+ ", sc=" + Utility.quoteJavaString(Default.ucd.getSpecialCase(i))
|
2001-08-30 20:50:18 +00:00
|
|
|
);
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
if (i > 0x180) i = 3 * i / 2;
|
|
|
|
}
|
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
static void checkCanonicalProperties() {
|
2002-04-23 01:59:16 +00:00
|
|
|
Default.setUCD();
|
|
|
|
System.out.println(Default.ucd.toString(0x1E0A));
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
System.out.println("Cross-checking canonical equivalence");
|
2002-04-23 01:59:16 +00:00
|
|
|
System.out.println("Version: " + Default.ucd.getVersion() + ", " + new Date(Default.ucd.getDate()));
|
2001-08-30 20:50:18 +00:00
|
|
|
showCanonicalDecomposition = true;
|
|
|
|
for (int q = 1; q < 2; ++q)
|
|
|
|
for (int i = 0; i <= 0x10FFFF; ++i) {
|
|
|
|
Utility.dot(i);
|
|
|
|
if (i == 0x0387) {
|
|
|
|
System.out.println("debug?");
|
|
|
|
}
|
2002-04-23 01:59:16 +00:00
|
|
|
byte type = Default.ucd.getDecompositionType(i);
|
2001-08-30 20:50:18 +00:00
|
|
|
if (type != CANONICAL) continue;
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
String s = Default.ucd.getDecompositionMapping(i);
|
2001-08-30 20:50:18 +00:00
|
|
|
int slen = UTF32.length32(s);
|
|
|
|
int j = UTF32.char32At(s, 0);
|
|
|
|
try {
|
|
|
|
if (q == 0) {
|
2002-04-23 01:59:16 +00:00
|
|
|
check(i, Default.ucd.getCategory(i), Default.ucd.getCategory(j), UCD_Names.GC, "GeneralCategory");
|
|
|
|
check(i, Default.ucd.getCombiningClass(i), Default.ucd.getCombiningClass(j), "CanonicalClass");
|
|
|
|
check(i, Default.ucd.getBidiClass(i), Default.ucd.getBidiClass(j), UCD_Names.BC, "BidiClass");
|
|
|
|
check(i, Default.ucd.getNumericValue(i), Default.ucd.getNumericValue(j), "NumericValue");
|
|
|
|
check(i, Default.ucd.getNumericType(i), Default.ucd.getNumericType(j), UCD_Names.NT, "NumericType");
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
if (false) {
|
2003-07-21 15:50:07 +00:00
|
|
|
for (byte k = LOWER; k < LIMIT_CASE; ++k) {
|
2002-04-23 01:59:16 +00:00
|
|
|
check(i, Default.ucd.getCase(i, SIMPLE, k), Default.ucd.getCase(j, SIMPLE, k), "Simple("+k+")");
|
|
|
|
check(i, Default.ucd.getCase(i, FULL, k), Default.ucd.getCase(j, FULL, k), "Full("+k+")");
|
2001-08-30 20:50:18 +00:00
|
|
|
}
|
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2002-04-23 01:59:16 +00:00
|
|
|
if (slen == 1) check(i, Default.ucd.getSpecialCase(i), Default.ucd.getSpecialCase(j), "SpecialCase");
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
for (byte k = 0; k < LIMIT_BINARY_PROPERTIES; ++k) {
|
|
|
|
if (k == Hex_Digit) continue;
|
|
|
|
if (k == Radical) continue;
|
|
|
|
if (k == UnifiedIdeograph) continue;
|
|
|
|
if (k == CompositionExclusion) continue;
|
2002-04-23 01:59:16 +00:00
|
|
|
check(i, Default.ucd.getBinaryProperty(i, k), Default.ucd.getBinaryProperty(j, k), UCD_Names.YN_TABLE, Default.ucd.getBinaryPropertiesID_fromIndex(k));
|
2001-08-30 20:50:18 +00:00
|
|
|
}
|
|
|
|
} else {
|
2002-04-23 01:59:16 +00:00
|
|
|
//check(i, Default.ucd.getLineBreak(i), Default.ucd.getLineBreak(j), UCD_Names.LB, "LineBreak");
|
|
|
|
//check(i, Default.ucd.getEastAsianWidth(i), Default.ucd.getEastAsianWidth(j), UCD_Names.EA, "EastAsian");
|
2001-08-30 20:50:18 +00:00
|
|
|
}
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
} catch (Exception e) {
|
|
|
|
System.out.println("Error: " + Utility.hex(i) + " " + e.getClass().getName() + e.getMessage());
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-09-06 01:30:31 +00:00
|
|
|
|
|
|
|
static void checkSpeed() {
|
|
|
|
int count = 1000000;
|
|
|
|
int sum = 0;
|
|
|
|
long start, end;
|
|
|
|
|
2001-09-19 23:33:52 +00:00
|
|
|
java.text.NumberFormat nf = java.text.NumberFormat.getPercentInstance();
|
|
|
|
|
|
|
|
start = System.currentTimeMillis();
|
|
|
|
for (int i = count; i >= 0; --i) {
|
|
|
|
sum += dummy0(i).length();
|
|
|
|
}
|
|
|
|
end = System.currentTimeMillis();
|
|
|
|
double base = end - start;
|
|
|
|
|
|
|
|
System.out.println("unsynchronized static char[]: " + nf.format((end - start)/base));
|
|
|
|
|
2001-09-06 01:30:31 +00:00
|
|
|
start = System.currentTimeMillis();
|
|
|
|
for (int i = count; i >= 0; --i) {
|
|
|
|
sum += dummy2(i).length();
|
|
|
|
}
|
|
|
|
end = System.currentTimeMillis();
|
2001-09-19 23:33:52 +00:00
|
|
|
System.out.println("synchronized static char[]: " + nf.format((end - start)/base));
|
2001-09-06 01:30:31 +00:00
|
|
|
|
|
|
|
start = System.currentTimeMillis();
|
|
|
|
for (int i = count; i >= 0; --i) {
|
|
|
|
sum += dummy1(i).length();
|
|
|
|
}
|
|
|
|
end = System.currentTimeMillis();
|
2001-09-19 23:33:52 +00:00
|
|
|
System.out.println("char[] each time: " + nf.format((end - start)/base));
|
2001-09-06 01:30:31 +00:00
|
|
|
|
|
|
|
start = System.currentTimeMillis();
|
|
|
|
for (int i = count; i >= 0; --i) {
|
|
|
|
sum += dummy3(i).length();
|
|
|
|
}
|
|
|
|
end = System.currentTimeMillis();
|
2001-09-19 23:33:52 +00:00
|
|
|
System.out.println("two valueofs: " + nf.format((end - start)/base));
|
2001-09-06 01:30:31 +00:00
|
|
|
|
|
|
|
System.out.println(sum);
|
|
|
|
}
|
|
|
|
|
|
|
|
static String dummy1(int a) {
|
|
|
|
char[] temp = new char[2];
|
|
|
|
temp[0] = (char)(a >>> 16);
|
|
|
|
temp[1] = (char)a;
|
|
|
|
return new String(temp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static char[] temp2 = new char[2];
|
|
|
|
|
|
|
|
static String dummy2(int a) {
|
|
|
|
synchronized (temp2) {
|
|
|
|
temp2[0] = (char)(a >>> 16);
|
|
|
|
temp2[1] = (char)a;
|
|
|
|
return new String(temp2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-09-19 23:33:52 +00:00
|
|
|
static String dummy0(int a) {
|
|
|
|
temp2[0] = (char)(a >>> 16);
|
|
|
|
temp2[1] = (char)a;
|
|
|
|
return new String(temp2);
|
|
|
|
}
|
|
|
|
|
2001-09-06 01:30:31 +00:00
|
|
|
static String dummy3(int a) {
|
|
|
|
return String.valueOf((char)(a >>> 16)) + (char)a;
|
|
|
|
}
|
|
|
|
|
2001-08-31 00:30:17 +00:00
|
|
|
|
2001-08-30 20:50:18 +00:00
|
|
|
}
|