| 75 | |
| 76 | static TArray<char> out; |
| 77 | const char *StringToUnicode(const char *cc, int size) |
| 78 | { |
| 79 | int ch; |
| 80 | const uint8_t *c = (const uint8_t*)cc; |
| 81 | int count = 0; |
| 82 | int count1 = 0; |
| 83 | out.Clear(); |
| 84 | while ((ch = (*c++) & 255)) |
| 85 | { |
| 86 | count1++; |
| 87 | if (ch >= 128) count += 2; |
| 88 | else count++; |
| 89 | if (count1 == size && size > 0) break; |
| 90 | } |
| 91 | if (count == count1) return cc; // string is pure ASCII. |
| 92 | // we need to convert |
| 93 | out.Resize(count + 1); |
| 94 | out.Last() = 0; |
| 95 | c = (const uint8_t*)cc; |
| 96 | int i = 0; |
| 97 | while ((ch = (*c++))) |
| 98 | { |
| 99 | utf8_encode(ch, (uint8_t*)&out[i], &count1); |
| 100 | i += count1; |
| 101 | } |
| 102 | return &out[0]; |
| 103 | } |
| 104 | |
| 105 | const char *UnicodeToString(const char *cc) |
| 106 | { |
no test coverage detected