diff options
author | crupest <crupest@outlook.com> | 2020-04-05 21:44:07 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-04-05 21:44:07 +0800 |
commit | abcaa16c897678fa3fa4cda3f23660e4ca46b841 (patch) | |
tree | 1ce5fb102548d28a33838f2c30d5ed4e6571abbf /include/cru/win | |
parent | 37bb421e963662e8203acbe3a03bdbd5d1f5858e (diff) | |
download | cru-abcaa16c897678fa3fa4cda3f23660e4ca46b841.tar.gz cru-abcaa16c897678fa3fa4cda3f23660e4ca46b841.tar.bz2 cru-abcaa16c897678fa3fa4cda3f23660e4ca46b841.zip |
...
Diffstat (limited to 'include/cru/win')
-rw-r--r-- | include/cru/win/native/window.hpp | 5 | ||||
-rw-r--r-- | include/cru/win/string.hpp | 8 |
2 files changed, 13 insertions, 0 deletions
diff --git a/include/cru/win/native/window.hpp b/include/cru/win/native/window.hpp index a137463b..a27a3384 100644 --- a/include/cru/win/native/window.hpp +++ b/include/cru/win/native/window.hpp @@ -156,6 +156,11 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow { Event<std::string> char_event_; Event<WindowNativeMessageEventArgs&> native_message_event_; + + // WM_CHAR may be sent twice successively with two utf-16 code units of + // surrogate pair when character is from supplementary planes. This field is + // used to save the previous one. + wchar_t last_wm_char_event_wparam_; }; class WinNativeWindowResolver : public WinNativeResource, diff --git a/include/cru/win/string.hpp b/include/cru/win/string.hpp index 3fdadbf8..b2bfd245 100644 --- a/include/cru/win/string.hpp +++ b/include/cru/win/string.hpp @@ -27,6 +27,14 @@ namespace cru::platform::win { std::string ToUtf8String(const std::wstring_view& string); std::wstring ToUtf16String(const std::string_view& string); +inline bool IsSurrogatePairLeading(wchar_t c) { + return c >= 0xD800 && c <= 0xDBFF; +} + +inline bool IsSurrogatePairTrailing(wchar_t c) { + return c >= 0xDC00 && c <= 0xDFFF; +} + using CodePoint = std::int32_t; constexpr CodePoint k_code_point_end = -1; |