MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / code_point_to_utf16

Function code_point_to_utf16

extlibs/sol3/include/sol/sol.hpp:11489–11509  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11487 }
11488
11489 inline encoded_result<char16_t> code_point_to_utf16(char32_t codepoint) {
11490 encoded_result<char16_t> er;
11491
11492 if (codepoint <= unicode_detail::last_bmp_value) {
11493 er.code_units_size = 1;
11494 er.code_units = std::array<char16_t, 4>{ { static_cast<char16_t>(codepoint) } };
11495 er.error = error_code::ok;
11496 }
11497 else {
11498 auto normal = codepoint - unicode_detail::normalizing_value;
11499 auto lead = unicode_detail::first_lead_surrogate + ((normal & unicode_detail::lead_surrogate_bitmask) >> unicode_detail::lead_shifted_bits);
11500 auto trail = unicode_detail::first_trail_surrogate + (normal & unicode_detail::trail_surrogate_bitmask);
11501 er.code_units = std::array<char16_t, 4>{ {
11502 static_cast<char16_t>(lead),
11503 static_cast<char16_t>(trail)
11504 } };
11505 er.code_units_size = 2;
11506 er.error = error_code::ok;
11507 }
11508 return er;
11509 }
11510
11511 inline encoded_result<char32_t> code_point_to_utf32(char32_t codepoint) {
11512 encoded_result<char32_t> er;

Callers 2

convertFunction · 0.85
getMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected