| 1109 | } |
| 1110 | |
| 1111 | void UnicodeUtil::utf8Normalize(UCharBuffer& data) |
| 1112 | { |
| 1113 | ICU* icu = loadICU("", ""); |
| 1114 | |
| 1115 | HalfStaticArray<USHORT, BUFFER_MEDIUM> utf16Buffer(data.getCount()); |
| 1116 | USHORT errCode; |
| 1117 | ULONG errPosition; |
| 1118 | ULONG utf16BufferLen = utf8ToUtf16(data.getCount(), data.begin(), data.getCount() * sizeof(USHORT), |
| 1119 | utf16Buffer.getBuffer(data.getCount()), &errCode, &errPosition); |
| 1120 | |
| 1121 | UTransliterator* trans = icu->getCiAiTransliterator(); |
| 1122 | |
| 1123 | if (trans) |
| 1124 | { |
| 1125 | const int32_t capacity = utf16Buffer.getCount() * sizeof(USHORT); |
| 1126 | int32_t len = utf16BufferLen / sizeof(USHORT); |
| 1127 | int32_t limit = len; |
| 1128 | |
| 1129 | UErrorCode errorCode = U_ZERO_ERROR; |
| 1130 | icu->utransTransUChars(trans, reinterpret_cast<UChar*>(utf16Buffer.begin()), |
| 1131 | &len, capacity, 0, &limit, &errorCode); |
| 1132 | icu->releaseCiAiTransliterator(trans); |
| 1133 | |
| 1134 | len = utf16ToUtf8(utf16BufferLen, utf16Buffer.begin(), |
| 1135 | len * 4, data.getBuffer(len * 4, false), |
| 1136 | &errCode, &errPosition); |
| 1137 | |
| 1138 | data.shrink(len); |
| 1139 | } |
| 1140 | } |
| 1141 | |
| 1142 | UnicodeUtil::ICU* UnicodeUtil::loadICU(const string& icuVersion, const string& configInfo) |
| 1143 | { |
nothing calls this directly
no test coverage detected