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

Function api_val_wstring

include/hx/CFFINekoLoader.h:332–365  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

330
331
332const wchar_t *api_val_wstring(neko_value arg1)
333{
334 int len = api_val_strlen(arg1);
335
336 unsigned char *b = (unsigned char *)api_val_string(arg1);
337 wchar_t *result = (wchar_t *)dyn_alloc_private((len+1)*sizeof(wchar_t));
338 int l = 0;
339
340 for(int i=0;i<len;)
341 {
342 int c = b[i++];
343 if (c==0) break;
344 else if( c < 0x80 )
345 {
346 result[l++] = c;
347 }
348 else if( c < 0xE0 )
349 result[l++] = ( ((c & 0x3F) << 6) | (b[i++] & 0x7F) );
350 else if( c < 0xF0 )
351 {
352 int c2 = b[i++];
353 result[l++] = ( ((c & 0x1F) << 12) | ((c2 & 0x7F) << 6) | ( b[i++] & 0x7F) );
354 }
355 else
356 {
357 int c2 = b[i++];
358 int c3 = b[i++];
359 result[l++] = ( ((c & 0x0F) << 18) | ((c2 & 0x7F) << 12) | ((c3 << 6) & 0x7F) | (b[i++] & 0x7F) );
360 }
361 }
362 result[l] = '\0';
363
364 return result;
365}
366
367
368wchar_t * api_val_dup_wstring(neko_value inVal)

Callers 1

api_val_dup_wstringFunction · 0.85

Calls 2

api_val_strlenFunction · 0.85
api_val_stringFunction · 0.85

Tested by

no test coverage detected