Esempio n. 1
0
 private static bool NormalizeAndCheckString(
 string charString,
 int start,
 int length,
 Normalization form)
 {
     int i = start;
     var norm = new NormalizerInput(
        charString,
        start,
        length,
        form);
     var ch = 0;
     int endIndex = start + length;
     while ((ch = norm.ReadChar()) >= 0) {
       int c = charString[i];
       if ((c & 0x1ffc00) == 0xd800 && i + 1 < endIndex &&
       charString[i + 1] >= 0xdc00 && charString[i + 1] <= 0xdfff) {
     // Get the Unicode code point for the surrogate pair
     c = 0x10000 + ((c - 0xd800) << 10) + (charString[i + 1] - 0xdc00);
     ++i;
       } else if ((c & 0x1ff800) == 0xd800) {
     // unpaired surrogate
     return false;
       }
       ++i;
       if (c != ch) {
     return false;
       }
     }
     return i == endIndex;
 }
Esempio n. 2
0
     private static bool NormalizeAndCheck(
 int[] charArray,
 int start,
 int length,
 Normalization form)
     {
         var i = 0;
         int ch;
         var input = new NormalizerInput(
         new PartialArrayCharacterInput(charArray, start, length),
         form);
         while ((ch = input.ReadChar()) >= 0) {
             if (i >= length) {
                 return false;
             }
             if (ch != charArray[start + i]) {
                 return false;
             }
             ++i;
         }
         return i == length;
     }