MCPcopy Create free account
hub / github.com/ZDoom/gzdoom / StringToUnicode

Function StringToUnicode

src/common/engine/serializer.cpp:77–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75
76static TArray<char> out;
77const 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
105const char *UnicodeToString(const char *cc)
106{

Callers 2

StringUMethod · 0.85
StringMethod · 0.85

Calls 3

utf8_encodeFunction · 0.50
ClearMethod · 0.45
ResizeMethod · 0.45

Tested by

no test coverage detected