static int GetNormalizedStringLength (int ch) { int start = charMapIndex [NUtil.MapIdx (ch)]; int i = start; while (mappedChars [i] != 0) i++; return i - start; }
private void SetCanonProp(int cp, int cpEnd, int flag) { int idx = NUtil.MapIdx(cp); if (cpEnd < 0) { mapIndex [idx] = flag; } else { int idxEnd = NUtil.MapIdx(cpEnd); for (int i = idx; i <= idxEnd; i++) { mapIndex [i] = flag; } } }
private void RebaseUCD() { mappings.Sort(comparer); // mappedChars[0] = 0. This assures that value 0 of // mapIndex means there is no mapping. int count = 1; int [] compressedMapping = new int [mappedCharCount]; // Update map index. int [] newMapIndex = new int [mappings.Count]; for (int mi = 0; mi < mappings.Count; mi++) { CharMapping m = (CharMapping)mappings [mi]; if (mi > 0 && 0 == comparer.Compare( mappings [mi - 1], mappings [mi])) { newMapIndex [mi] = newMapIndex [mi - 1]; continue; } newMapIndex [mi] = count; for (int i = m.MapIndex; mappedChars [i] != 0; i++) { compressedMapping [count++] = mappedChars [i]; } compressedMapping [count++] = 0; } for (int mi = 0; mi < mappings.Count; mi++) { ((CharMapping)mappings [mi]).MapIndex = newMapIndex [mi]; } int [] compressedMapIndex = new int [mapIndex.Length]; foreach (CharMapping m in mappings) { if (m.CodePoint <= char.MaxValue) { compressedMapIndex [NUtil.MapIdx(m.CodePoint)] = m.MapIndex; } } mappedChars = compressedMapping; mapIndex = compressedMapIndex; mappedCharCount = count; }
static int CharMapIdx (int cp) { return charMapIndex [NUtil.MapIdx (cp)]; }