Java Code Examples for com.ibm.icu.lang.UCharacter#getUnicodeVersion()

The following examples show how to use com.ibm.icu.lang.UCharacter#getUnicodeVersion() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StringPrep.java    From fitnotifications with Apache License 2.0 5 votes vote down vote up
private StringPrep(ByteBuffer bytes) throws IOException {
    StringPrepDataReader reader = new StringPrepDataReader(bytes);

    // read the indexes
    indexes = reader.readIndexes(INDEX_TOP);

    sprepTrie = new CharTrie(bytes, null);

    //indexes[INDEX_MAPPING_DATA_SIZE] store the size of mappingData in bytes
    // load the rest of the data data and initialize the data members
    mappingData = reader.read(indexes[INDEX_MAPPING_DATA_SIZE]/2);

    // get the options
    doNFKC            = ((indexes[OPTIONS] & NORMALIZATION_ON) > 0);
    checkBiDi         = ((indexes[OPTIONS] & CHECK_BIDI_ON) > 0);
    sprepUniVer   = getVersionInfo(reader.getUnicodeVersion());
    normCorrVer   = getVersionInfo(indexes[NORM_CORRECTNS_LAST_UNI_VERSION]);
    VersionInfo normUniVer = UCharacter.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");
    }

    if(checkBiDi) {
        bdp=UBiDiProps.INSTANCE;
    }
}
 
Example 2
Source File: StringPrep.java    From trekarta with GNU General Public License v3.0 5 votes vote down vote up
private StringPrep(ByteBuffer bytes) throws IOException {
    StringPrepDataReader reader = new StringPrepDataReader(bytes);

    // read the indexes
    indexes = reader.readIndexes(INDEX_TOP);

    sprepTrie = new CharTrie(bytes, null);

    //indexes[INDEX_MAPPING_DATA_SIZE] store the size of mappingData in bytes
    // load the rest of the data data and initialize the data members
    mappingData = reader.read(indexes[INDEX_MAPPING_DATA_SIZE]/2);

    // get the options
    doNFKC            = ((indexes[OPTIONS] & NORMALIZATION_ON) > 0);
    checkBiDi         = ((indexes[OPTIONS] & CHECK_BIDI_ON) > 0);
    sprepUniVer   = getVersionInfo(reader.getUnicodeVersion());
    normCorrVer   = getVersionInfo(indexes[NORM_CORRECTNS_LAST_UNI_VERSION]);
    VersionInfo normUniVer = UCharacter.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");
    }

    if(checkBiDi) {
        bdp=UBiDiProps.INSTANCE;
    }
}