MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / utf32ToUtf16SurrogatePair

Function utf32ToUtf16SurrogatePair

source/core/StarUnicode.cpp:258–271  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

256}
257
258pair<Utf32Type, Maybe<Utf32Type>> utf32ToUtf16SurrogatePair(Utf32Type codepoint) {
259 if (codepoint >= MIN_PAIR) {
260 codepoint -= MIN_PAIR;
261 Utf32Type lead = (codepoint >> 10) + MIN_LEAD;
262 Utf32Type trail = (codepoint & SURR_MASK) + MIN_TRAIL;
263
264 if (!isUtf16LeadSurrogate(lead))
265 throw UnicodeException("Invalid codepoint passed to utf32ToUtf16SurrogatePair");
266
267 return {lead, trail};
268 }
269
270 return {codepoint, {}};
271}
272
273}

Callers 1

hexStringFromUtf32Function · 0.85

Calls 1

isUtf16LeadSurrogateFunction · 0.85

Tested by

no test coverage detected