blob: 4ea765b94b6b1f0bb8aff1c05340dd8a4533db23 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#pragma once
#include <util/system/types.h>
#include <util/system/yassert.h>
inline constexpr bool IsW16SurrogateLead(wchar16 c) noexcept {
return 0xD800 <= c && c <= 0xDBFF;
}
inline constexpr bool IsW16SurrogateTail(wchar16 c) noexcept {
return 0xDC00 <= c && c <= 0xDFFF;
}
inline size_t W16SymbolSize(const wchar16* begin, const wchar16* end) {
Y_ASSERT(begin < end);
if ((begin + 1 != end) && IsW16SurrogateLead(*begin) && IsW16SurrogateTail(*(begin + 1))) {
return 2;
}
return 1;
}
|