public static QuickCheck ( char c, int type ) : NormalizationCheck | ||
c | char | |
type | int | |
Результат | NormalizationCheck |
private unsafe static void Combine(StringBuilder sb, int start, int checkType) { for (int i = start; i < sb.Length; i++) { if (Normalization.QuickCheck(sb[i], checkType) != NormalizationCheck.Yes) { int num = i; while (i > 0) { if (Normalization.GetCombiningClass((int)sb[i]) == 0) { break; } i--; } int num2 = 0; while (i < num) { num2 = Normalization.GetPrimaryCompositeMapIndex(sb, (int)sb[i], i); if (num2 > 0) { break; } i++; } if (num2 == 0) { i = num; } else { int primaryCompositeFromMapIndex = Normalization.GetPrimaryCompositeFromMapIndex(num2); int normalizedStringLength = Normalization.GetNormalizedStringLength(primaryCompositeFromMapIndex); if (primaryCompositeFromMapIndex == 0 || normalizedStringLength == 0) { throw new SystemException("Internal error: should not happen. Input: " + sb); } int j = 0; sb.Insert(i++, (char)primaryCompositeFromMapIndex); while (j < normalizedStringLength) { if ((int)sb[i] == Normalization.mappedChars[num2 + j]) { sb.Remove(i, 1); j++; } else { i++; } } i = num - 1; } } } }
private static StringBuilder Combine(string source, int start, int checkType) { for (int i = 0; i < source.Length; i++) { if (Normalization.QuickCheck(source[i], checkType) != NormalizationCheck.Yes) { StringBuilder stringBuilder = new StringBuilder(source.Length + source.Length / 10); stringBuilder.Append(source); Normalization.Combine(stringBuilder, i, checkType); return(stringBuilder); } } return(null); }
public static bool IsNormalized(string source, int type) { int num = -1; for (int i = 0; i < source.Length; i++) { int num2 = (int)Normalization.GetCombiningClass((int)source[i]); if (num2 != 0 && num2 < num) { return(false); } num = num2; switch (Normalization.QuickCheck(source[i], type)) { case NormalizationCheck.No: return(false); case NormalizationCheck.Maybe: { switch (type) { case 0: case 2: return(source == Normalization.Normalize(source, type)); } int num3 = i; while (i > 0) { if (Normalization.GetCombiningClass((int)source[i]) == 0) { break; } i--; } while (i < num3) { if (Normalization.GetPrimaryCompositeCharIndex(source, i) != 0) { return(false); } i++; } break; } } } return(true); }
private static void Decompose(string source, ref StringBuilder sb, int checkType) { int[] array = null; int num = 0; for (int i = 0; i < source.Length; i++) { if (Normalization.QuickCheck(source[i], checkType) == NormalizationCheck.No) { Normalization.DecomposeChar(ref sb, ref array, source, i, ref num); } } if (sb != null) { sb.Append(source, num, source.Length - num); } Normalization.ReorderCanonical(source, ref sb, 1); }