summaryrefslogtreecommitdiffstats
path: root/ui/events
diff options
context:
space:
mode:
authoryukishiino@chromium.org <yukishiino@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-13 12:59:11 +0000
committeryukishiino@chromium.org <yukishiino@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-13 12:59:11 +0000
commitd87e618b08ffd716085acb367c3837cb1ac90ef5 (patch)
tree601941ddffd78b3f95a9aabc92482ee113406978 /ui/events
parentc9ed8e4dadd5dffb38571a82bd3ef55327dab853 (diff)
downloadchromium_src-d87e618b08ffd716085acb367c3837cb1ac90ef5.zip
chromium_src-d87e618b08ffd716085acb367c3837cb1ac90ef5.tar.gz
chromium_src-d87e618b08ffd716085acb367c3837cb1ac90ef5.tar.bz2
aura: Supports text input on non UTF-8 environments.
We have assumed that XLookupString always returns a UTF-8 string, but it's not true. It could be any other encoding depending on the system locale and we have to support it. The root cause of the Issue 376893 is 1. XLookupString returns a ISO-8859-1 string (for example) 2. We converts it by UTF8ToUTF16. 3. The resulting character code is zero. 4. Cannot input a (non-ASCII) character. BUG=376893 Review URL: https://codereview.chromium.org/323023002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277003 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/events')
-rw-r--r--ui/events/keycodes/keyboard_code_conversion_x.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/ui/events/keycodes/keyboard_code_conversion_x.cc b/ui/events/keycodes/keyboard_code_conversion_x.cc
index 8e420ab..5d6c6ac 100644
--- a/ui/events/keycodes/keyboard_code_conversion_x.cc
+++ b/ui/events/keycodes/keyboard_code_conversion_x.cc
@@ -13,6 +13,7 @@
#include "base/basictypes.h"
#include "base/logging.h"
#include "base/strings/stringprintf.h"
+#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/events/keycodes/dom4/keycode_converter.h"
@@ -436,9 +437,11 @@ uint16 GetCharacterFromXEvent(XEvent* xev) {
int bytes_written = XLookupString(&xev->xkey, buf, 6, NULL, NULL);
DCHECK_LE(bytes_written, 6);
- base::string16 result;
- return (bytes_written > 0 && base::UTF8ToUTF16(buf, bytes_written, &result) &&
- result.length() == 1) ? result[0] : 0;
+ if (bytes_written <= 0)
+ return 0;
+ const base::string16& result = base::WideToUTF16(
+ base::SysNativeMBToWide(base::StringPiece(buf, bytes_written)));
+ return result.length() == 1 ? result[0] : 0;
}
unsigned int DefaultXKeysymFromHardwareKeycode(unsigned int hardware_code) {