Java Code Examples for com.ibm.icu.lang.UCharacter#FOLD_CASE_DEFAULT
The following examples show how to use
com.ibm.icu.lang.UCharacter#FOLD_CASE_DEFAULT .
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: UCaseProps.java From fitnotifications with Apache License 2.0 | 4 votes |
public final int fold(int c, int options) { int props=trie.get(c); if(!propsHasException(props)) { if(getTypeFromProps(props)>=UPPER) { c+=getDelta(props); } } else { int excOffset=getExceptionsOffset(props); int excWord=exceptions[excOffset++]; int index; if((excWord&EXC_CONDITIONAL_FOLD)!=0) { /* special case folding mappings, hardcoded */ if((options&FOLD_CASE_OPTIONS_MASK)==UCharacter.FOLD_CASE_DEFAULT) { /* default mappings */ if(c==0x49) { /* 0049; C; 0069; # LATIN CAPITAL LETTER I */ return 0x69; } else if(c==0x130) { /* no simple case folding for U+0130 */ return c; } } else { /* Turkic mappings */ if(c==0x49) { /* 0049; T; 0131; # LATIN CAPITAL LETTER I */ return 0x131; } else if(c==0x130) { /* 0130; T; 0069; # LATIN CAPITAL LETTER I WITH DOT ABOVE */ return 0x69; } } } if(hasSlot(excWord, EXC_FOLD)) { index=EXC_FOLD; } else if(hasSlot(excWord, EXC_LOWER)) { index=EXC_LOWER; } else { return c; } c=getSlotValue(excWord, index, excOffset); } return c; }
Example 2
Source File: UCaseProps.java From fitnotifications with Apache License 2.0 | 4 votes |
public final int toFullFolding(int c, StringBuilder out, int options) { int result; int props; result=c; props=trie.get(c); if(!propsHasException(props)) { if(getTypeFromProps(props)>=UPPER) { result=c+getDelta(props); } } else { int excOffset=getExceptionsOffset(props), excOffset2; int excWord=exceptions[excOffset++]; int full, index; excOffset2=excOffset; if((excWord&EXC_CONDITIONAL_FOLD)!=0) { /* use hardcoded conditions and mappings */ if((options&FOLD_CASE_OPTIONS_MASK)==UCharacter.FOLD_CASE_DEFAULT) { /* default mappings */ if(c==0x49) { /* 0049; C; 0069; # LATIN CAPITAL LETTER I */ return 0x69; } else if(c==0x130) { /* 0130; F; 0069 0307; # LATIN CAPITAL LETTER I WITH DOT ABOVE */ out.append(iDot); return 2; } } else { /* Turkic mappings */ if(c==0x49) { /* 0049; T; 0131; # LATIN CAPITAL LETTER I */ return 0x131; } else if(c==0x130) { /* 0130; T; 0069; # LATIN CAPITAL LETTER I WITH DOT ABOVE */ return 0x69; } } } else if(hasSlot(excWord, EXC_FULL_MAPPINGS)) { long value=getSlotValueAndOffset(excWord, EXC_FULL_MAPPINGS, excOffset); full=(int)value&0xffff; /* start of full case mapping strings */ excOffset=(int)(value>>32)+1; /* skip the lowercase result string */ excOffset+=full&FULL_LOWER; full=(full>>4)&0xf; if(full!=0) { /* set the output pointer to the result string */ out.append(exceptions, excOffset, full); /* return the string length */ return full; } } if(hasSlot(excWord, EXC_FOLD)) { index=EXC_FOLD; } else if(hasSlot(excWord, EXC_LOWER)) { index=EXC_LOWER; } else { return ~c; } result=getSlotValue(excWord, index, excOffset2); } return (result==c) ? ~result : result; }
Example 3
Source File: UCaseProps.java From trekarta with GNU General Public License v3.0 | 4 votes |
public final int fold(int c, int options) { int props=trie.get(c); if(!propsHasException(props)) { if(isUpperOrTitleFromProps(props)) { c+=getDelta(props); } } else { int excOffset=getExceptionsOffset(props); int excWord=exceptions.charAt(excOffset++); int index; if((excWord&EXC_CONDITIONAL_FOLD)!=0) { /* special case folding mappings, hardcoded */ if((options&FOLD_CASE_OPTIONS_MASK)==UCharacter.FOLD_CASE_DEFAULT) { /* default mappings */ if(c==0x49) { /* 0049; C; 0069; # LATIN CAPITAL LETTER I */ return 0x69; } else if(c==0x130) { /* no simple case folding for U+0130 */ return c; } } else { /* Turkic mappings */ if(c==0x49) { /* 0049; T; 0131; # LATIN CAPITAL LETTER I */ return 0x131; } else if(c==0x130) { /* 0130; T; 0069; # LATIN CAPITAL LETTER I WITH DOT ABOVE */ return 0x69; } } } if((excWord&EXC_NO_SIMPLE_CASE_FOLDING)!=0) { return c; } if(hasSlot(excWord, EXC_DELTA) && isUpperOrTitleFromProps(props)) { int delta=getSlotValue(excWord, EXC_DELTA, excOffset); return (excWord&EXC_DELTA_IS_NEGATIVE)==0 ? c+delta : c-delta; } if(hasSlot(excWord, EXC_FOLD)) { index=EXC_FOLD; } else if(hasSlot(excWord, EXC_LOWER)) { index=EXC_LOWER; } else { return c; } c=getSlotValue(excWord, index, excOffset); } return c; }
Example 4
Source File: CaseMapImpl.java From trekarta with GNU General Public License v3.0 | 4 votes |
/** * caseLocale >= 0: Lowercases [srcStart..srcLimit[ but takes context [0..srcLength[ into account. * caseLocale < 0: Case-folds [srcStart..srcLimit[. */ private static void internalToLower(int caseLocale, int options, CharSequence src, int srcStart, int srcLimit, StringContextIterator iter, Appendable dest, Edits edits) throws IOException { byte[] latinToLower; if (caseLocale == UCaseProps.LOC_ROOT || (caseLocale >= 0 ? !(caseLocale == UCaseProps.LOC_TURKISH || caseLocale == UCaseProps.LOC_LITHUANIAN) : (options & UCaseProps.FOLD_CASE_OPTIONS_MASK) == UCharacter.FOLD_CASE_DEFAULT)) { latinToLower = UCaseProps.LatinCase.TO_LOWER_NORMAL; } else { latinToLower = UCaseProps.LatinCase.TO_LOWER_TR_LT; } int prev = srcStart; int srcIndex = srcStart; outerLoop: for (;;) { // fast path for simple cases char lead; for (;;) { if (srcIndex >= srcLimit) { break outerLoop; } lead = src.charAt(srcIndex); int delta; if (lead < UCaseProps.LatinCase.LONG_S) { byte d = latinToLower[lead]; if (d == UCaseProps.LatinCase.EXC) { break; } ++srcIndex; if (d == 0) { continue; } delta = d; } else if (lead >= 0xd800) { break; // surrogate or higher } else { int props = CASE_TRIE.getFromU16SingleLead(lead); if (UCaseProps.propsHasException(props)) { break; } ++srcIndex; if (!UCaseProps.isUpperOrTitleFromProps(props) || (delta = UCaseProps.getDelta(props)) == 0) { continue; } } lead += delta; appendUnchanged(src, prev, srcIndex - 1 - prev, dest, options, edits); dest.append(lead); if (edits != null) { edits.addReplace(1, 1); } prev = srcIndex; } // slow path int cpStart = srcIndex++; char trail; int c; if (Character.isHighSurrogate(lead) && srcIndex < srcLimit && Character.isLowSurrogate(trail = src.charAt(srcIndex))) { c = Character.toCodePoint(lead, trail); ++srcIndex; } else { c = lead; } // We need to append unchanged text before calling the UCaseProps.toFullXyz() methods // because they will sometimes append their mapping to dest, // and that must be after copying the previous text. appendUnchanged(src, prev, cpStart - prev, dest, options, edits); prev = cpStart; if (caseLocale >= 0) { if (iter == null) { iter = new StringContextIterator(src, cpStart, srcIndex); } else { iter.setCPStartAndLimit(cpStart, srcIndex); } c = UCaseProps.INSTANCE.toFullLower(c, iter, dest, caseLocale); } else { c = UCaseProps.INSTANCE.toFullFolding(c, dest, options); } if (c >= 0) { appendResult(c, dest, srcIndex - cpStart, options, edits); prev = srcIndex; } } appendUnchanged(src, prev, srcIndex - prev, dest, options, edits); }