| 256 | } |
| 257 | |
| 258 | pair<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 | } |
no test coverage detected