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

Function toAsciiString

src/cpp/encoding/Encodings.cpp:443–460  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

441 }
442
443 String toAsciiString(const View<uint8_t>& buffer)
444 {
445 auto bytes = buffer.length / sizeof(char16_t);
446 auto chars = View<char>(hx::InternalNew(bytes + 1, false), bytes * sizeof(char));
447 auto i = int64_t{ 0 };
448 auto k = int64_t{ 0 };
449
450 while (i < buffer.length)
451 {
452 auto p = cpp::encoding::Utf16::codepoint(buffer.slice(i));
453
454 chars[k++] = static_cast<char>(p);
455
456 i += cpp::encoding::Utf16::getByteCount(p);
457 }
458
459 return String(chars.ptr.ptr, chars.length);
460 }
461}
462
463bool cpp::encoding::Utf16::isEncoded(const String& string)

Callers 1

decodeMethod · 0.85

Calls 4

InternalNewFunction · 0.85
getByteCountFunction · 0.50
StringClass · 0.50
sliceMethod · 0.45

Tested by

no test coverage detected