mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-08 23:10:40 +00:00
ICU-3170 synch up with ICU4C
X-SVN-Rev: 14891
This commit is contained in:
parent
ec825e9a79
commit
d7242682d5
4 changed files with 47 additions and 22 deletions
|
@ -309,7 +309,7 @@ final class NormalizerDataReader implements ICUBinary.Authenticate {
|
|||
throws IOException{
|
||||
if(debug) System.out.println("Bytes in inputStream " + inputStream.available());
|
||||
|
||||
ICUBinary.readHeader(inputStream, DATA_FORMAT_ID, this);
|
||||
unicodeVersion = ICUBinary.readHeader(inputStream, DATA_FORMAT_ID, this);
|
||||
|
||||
if(debug) System.out.println("Bytes left in inputStream " +inputStream.available());
|
||||
|
||||
|
@ -404,6 +404,9 @@ final class NormalizerDataReader implements ICUBinary.Authenticate {
|
|||
&& version[3] == DATA_FORMAT_VERSION[3];
|
||||
}
|
||||
|
||||
public byte[] getUnicodeVersion(){
|
||||
return unicodeVersion;
|
||||
}
|
||||
// private data members -------------------------------------------------
|
||||
|
||||
|
||||
|
@ -411,6 +414,8 @@ final class NormalizerDataReader implements ICUBinary.Authenticate {
|
|||
* ICU data file input stream
|
||||
*/
|
||||
private DataInputStream dataInputStream;
|
||||
|
||||
private byte[] unicodeVersion;
|
||||
|
||||
/**
|
||||
* File format version that this class understands.
|
||||
|
|
|
@ -16,6 +16,7 @@ import com.ibm.icu.text.UTF16;
|
|||
import com.ibm.icu.text.UnicodeSet;
|
||||
import com.ibm.icu.text.UnicodeSetIterator;
|
||||
import com.ibm.icu.util.RangeValueIterator;
|
||||
import com.ibm.icu.util.VersionInfo;
|
||||
import com.ibm.icu.lang.UCharacter;
|
||||
|
||||
/**
|
||||
|
@ -219,17 +220,19 @@ public final class NormalizerImpl {
|
|||
/****************************************************/
|
||||
|
||||
|
||||
static FCDTrieImpl fcdTrieImpl;
|
||||
static NormTrieImpl normTrieImpl;
|
||||
static AuxTrieImpl auxTrieImpl;
|
||||
private static FCDTrieImpl fcdTrieImpl;
|
||||
private static NormTrieImpl normTrieImpl;
|
||||
private static AuxTrieImpl auxTrieImpl;
|
||||
private static int[] indexes;
|
||||
static char[] combiningTable;
|
||||
static char[] extraData;
|
||||
static Object[] canonStartSets;
|
||||
private static char[] combiningTable;
|
||||
private static char[] extraData;
|
||||
private static Object[] canonStartSets;
|
||||
|
||||
static boolean isDataLoaded;
|
||||
static boolean isFormatVersion_2_1;
|
||||
static boolean isFormatVersion_2_2;
|
||||
private static boolean isDataLoaded;
|
||||
private static boolean isFormatVersion_2_1;
|
||||
private static boolean isFormatVersion_2_2;
|
||||
private static byte[] unicodeVersion;
|
||||
|
||||
/**
|
||||
* Default buffer size of datafile
|
||||
*/
|
||||
|
@ -325,7 +328,7 @@ public final class NormalizerImpl {
|
|||
||
|
||||
(formatVersion[0]==2 && formatVersion[1]>=2)
|
||||
);
|
||||
|
||||
unicodeVersion = reader.getUnicodeVersion();
|
||||
b.close();
|
||||
}
|
||||
}
|
||||
|
@ -429,7 +432,10 @@ public final class NormalizerImpl {
|
|||
}
|
||||
return norm32;
|
||||
}
|
||||
|
||||
public static VersionInfo getUnicodeVersion(){
|
||||
return VersionInfo.getInstance(unicodeVersion[0], unicodeVersion[1],
|
||||
unicodeVersion[2], unicodeVersion[3]);
|
||||
}
|
||||
public static char getFCD16(char c) {
|
||||
return FCDTrieImpl.fcdTrie.getLeadValue(c);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ package com.ibm.icu.text;
|
|||
import com.ibm.icu.impl.NormalizerImpl;
|
||||
import com.ibm.icu.impl.UCharacterProperty;
|
||||
import com.ibm.icu.lang.UCharacter;
|
||||
import com.ibm.icu.util.VersionInfo;
|
||||
|
||||
import java.text.CharacterIterator;
|
||||
import com.ibm.icu.impl.Utility;
|
||||
|
@ -2753,5 +2754,15 @@ public final class Normalizer implements Cloneable{
|
|||
result=NormalizerImpl.cmpEquivFold(s1, s1Start, s1Limit,
|
||||
s2, s2Start, s2Limit, options);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the Unicode version burned into the Normalization data file
|
||||
* @return VersionInfo version information of the normalizer
|
||||
* @internal
|
||||
* @author ram
|
||||
*/
|
||||
static VersionInfo getUnicodeVersion(){
|
||||
return NormalizerImpl.getUnicodeVersion();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,9 +71,8 @@ public final class StringPrep {
|
|||
private static final int UNASSIGNED = 0x0000;
|
||||
private static final int MAP = 0x0001;
|
||||
private static final int PROHIBITED = 0x0002;
|
||||
private static final int LABEL_SEPARATOR = 0x0003;
|
||||
private static final int DELETE = 0x0004;
|
||||
private static final int TYPE_LIMIT = 0x0005;
|
||||
private static final int DELETE = 0x0003;
|
||||
private static final int TYPE_LIMIT = 0x0004;
|
||||
|
||||
private static final int NORMALIZATION_ON = 0x0001;
|
||||
private static final int CHECK_BIDI_ON = 0x0002;
|
||||
|
@ -123,11 +122,11 @@ public final class StringPrep {
|
|||
// format version of the data file
|
||||
private byte[] formatVersion;
|
||||
// the version of Unicode supported by the data file
|
||||
private VersionInfo unicodeVersion;
|
||||
private VersionInfo sprepUniVer;
|
||||
// the Unicode version of last entry in the
|
||||
// NormalizationCorrections.txt file if normalization
|
||||
// is turned on
|
||||
private VersionInfo normVersion;
|
||||
private VersionInfo normCorrVer;
|
||||
// Option to turn on Normalization
|
||||
private boolean doNFKC;
|
||||
// Option to turn on checking for BiDi rules
|
||||
|
@ -186,9 +185,13 @@ public final class StringPrep {
|
|||
// get the options
|
||||
doNFKC = ((indexes[OPTIONS] & NORMALIZATION_ON) > 0);
|
||||
checkBiDi = ((indexes[OPTIONS] & CHECK_BIDI_ON) > 0);
|
||||
unicodeVersion = getVersionInfo(reader.getUnicodeVersion());
|
||||
normVersion = getVersionInfo(indexes[NORM_CORRECTNS_LAST_UNI_VERSION]);
|
||||
if(normVersion.compareTo(UCharacter.getUnicodeVersion())>0){
|
||||
sprepUniVer = getVersionInfo(reader.getUnicodeVersion());
|
||||
normCorrVer = getVersionInfo(indexes[NORM_CORRECTNS_LAST_UNI_VERSION]);
|
||||
VersionInfo normUniVer = Normalizer.getUnicodeVersion();
|
||||
if(normUniVer.compareTo(sprepUniVer) < 0 && /* the Unicode version of SPREP file must be less than the Unicode Vesion of the normalization data */
|
||||
normUniVer.compareTo(normCorrVer) < 0 && /* the Unicode version of the NormalizationCorrections.txt file should be less than the Unicode Vesion of the normalization data */
|
||||
((indexes[OPTIONS] & NORMALIZATION_ON) > 0) /* normalization turned on*/
|
||||
){
|
||||
throw new IOException("Normalization Correction version not supported");
|
||||
}
|
||||
b.close();
|
||||
|
@ -248,7 +251,7 @@ public final class StringPrep {
|
|||
char result = 0;
|
||||
int ch = UCharacterIterator.DONE;
|
||||
StringBuffer dest = new StringBuffer();
|
||||
boolean allowUnassigned = (boolean) ((options & ALLOW_UNASSIGNED)>0);
|
||||
boolean allowUnassigned = ((options & ALLOW_UNASSIGNED)>0);
|
||||
|
||||
while((ch=iter.nextCodePoint())!= UCharacterIterator.DONE){
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue