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

Function utf32FromUtf16SurrogatePair

source/core/StarUnicode.cpp:244–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

242}
243
244Utf32Type utf32FromUtf16SurrogatePair(Utf32Type lead, Utf32Type trail) {
245 if (!isUtf16LeadSurrogate(lead))
246 throw UnicodeException("Invalid lead surrogate passed to utf32FromUtf16SurrogatePair");
247 if (!isUtf16TrailSurrogate(trail))
248 throw UnicodeException("Invalid trail surrogate passed to utf32FromUtf16SurrogatePair");
249
250 lead -= MIN_LEAD;
251 trail -= MIN_TRAIL;
252
253 Utf32Type codepoint = (lead << 10) + trail + MIN_PAIR;
254
255 return codepoint;
256}
257
258pair<Utf32Type, Maybe<Utf32Type>> utf32ToUtf16SurrogatePair(Utf32Type codepoint) {
259 if (codepoint >= MIN_PAIR) {

Callers 1

hexStringToUtf32Function · 0.85

Calls 2

isUtf16LeadSurrogateFunction · 0.85
isUtf16TrailSurrogateFunction · 0.85

Tested by

no test coverage detected