From 47ed3f4db59fdc52756f2b0b89a72028e5547c7b Mon Sep 17 00:00:00 2001 From: Weiyi Wang Date: Mon, 4 Mar 2019 10:33:23 -0500 Subject: [PATCH] applet/swkbd: use UTF-16 string to test string size Also removed a TODO as it is verified that max_text_length is inclusive (allows size = max_text_length) --- src/core/frontend/applets/swkbd.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/frontend/applets/swkbd.cpp b/src/core/frontend/applets/swkbd.cpp index 8d10a07429..6c74429138 100644 --- a/src/core/frontend/applets/swkbd.cpp +++ b/src/core/frontend/applets/swkbd.cpp @@ -52,8 +52,10 @@ ValidationError SoftwareKeyboard::ValidateInput(const std::string& input) const return error; } - // TODO(jroweboy): Is max_text_length inclusive or exclusive? - if (input.size() > config.max_text_length) { + // 3DS uses UTF-16 string to test string size + std::u16string u16input = Common::UTF8ToUTF16(input); + + if (u16input.size() > config.max_text_length) { return ValidationError::MaxLengthExceeded; } @@ -62,7 +64,7 @@ ValidationError SoftwareKeyboard::ValidateInput(const std::string& input) const bool is_empty = input.empty(); switch (config.accept_mode) { case AcceptedInput::FixedLength: - if (input.size() != config.max_text_length) { + if (u16input.size() != config.max_text_length) { return ValidationError::FixedLengthRequired; } break;