Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Unified Diff: ui/events/keycodes/keyboard_code_conversion_x.cc

Issue 323023002: aura: Supports text input on non UTF-8 environments. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/keycodes/keyboard_code_conversion_x.cc
diff --git a/ui/events/keycodes/keyboard_code_conversion_x.cc b/ui/events/keycodes/keyboard_code_conversion_x.cc
index 8e420ab29193b7c769b2e4b703522db0d48c6302..5d6c6ace60609550e06a34e47da506a94bef181b 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) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698