MCPcopy Create free account
hub / github.com/HaxeFoundation/hxcpp / TConvertToUTF8

Function TConvertToUTF8

src/String.cpp:261–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

259
260template<typename T>
261char *TConvertToUTF8(const T *inStr, int *ioLen, hx::IStringAlloc *inBuffer,bool)
262{
263 int len = 0;
264 int chars = 0;
265 if (ioLen==0 || *ioLen==0)
266 {
267 while(inStr[len])
268 chars += UTF8Bytes(inStr[len++]);
269 }
270 else
271 {
272 len = *ioLen;
273 for(int i=0;i<len;i++)
274 chars += UTF8Bytes(inStr[i]);
275 }
276
277 char *buf = inBuffer ? (char *)inBuffer->allocBytes(chars+1) :
278 (char *)NewGCPrivate(0,chars+1);
279 char *ptr = buf;
280 for(int i=0;i<len;i++)
281 UTF8EncodeAdvance(ptr,inStr[i]);
282 *ptr = 0;
283 if (ioLen)
284 *ioLen = chars;
285
286 return buf;
287}
288
289
290template<>

Callers 4

TCopyStringFunction · 0.85
utf8_strMethod · 0.85

Calls 5

UTF8BytesFunction · 0.85
NewGCPrivateFunction · 0.85
UTF8EncodeAdvanceFunction · 0.85
Char16AdvanceFunction · 0.85
allocBytesMethod · 0.45

Tested by

no test coverage detected