MCPcopy Create free account
hub / github.com/NativeScript/android / utf8_length_from_utf32

Function utf8_length_from_utf32

test-app/runtime/src/main/cpp/ada/ada.cpp:245–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

243}
244
245size_t utf8_length_from_utf32(const char32_t* buf, size_t len) {
246 // We are not BOM aware.
247 const uint32_t* p = reinterpret_cast<const uint32_t*>(buf);
248 size_t counter{0};
249 for (size_t i = 0; i != len; ++i) {
250 ++counter; // ASCII
251 counter += static_cast<size_t>(p[i] > 0x7F); // two-byte
252 counter += static_cast<size_t>(p[i] > 0x7FF); // three-byte
253 counter += static_cast<size_t>(p[i] > 0xFFFF); // four-bytes
254 }
255 return counter;
256}
257
258size_t utf32_length_from_utf8(const char* buf, size_t len) {
259 const int8_t* p = reinterpret_cast<const int8_t*>(buf);

Callers 1

to_unicodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected