Add support for non-ASCII characters to chat console
authorShadowNinja <shadowninja@minetest.net>
Sun, 28 Feb 2016 18:27:54 +0000 (13:27 -0500)
committerShadowNinja <shadowninja@minetest.net>
Thu, 3 Mar 2016 04:23:31 +0000 (23:23 -0500)
This still only supports 256 characters, but that's because
Irrlicht's clipboard handlers don't support wide characters.

src/guiChatConsole.cpp

index d1351a0f73ae5003708cfa89b2ea3622a44067fc..d59937c31df3f9367218e88c2600c3ddfb30a833 100644 (file)
@@ -536,7 +536,8 @@ bool GUIChatConsole::OnEvent(const SEvent& event)
                        // Copy text to clipboard
                        if (prompt.getCursorLength() <= 0)
                                return true;
-                       std::string selected = wide_to_narrow(prompt.getSelection());
+                       std::wstring wselected = prompt.getSelection();
+                       std::string selected(wselected.begin(), wselected.end());
                        Environment->getOSOperator()->copyToClipboard(selected.c_str());
                        return true;
                }
@@ -553,8 +554,10 @@ bool GUIChatConsole::OnEvent(const SEvent& event)
                        }
                        IOSOperator *os_operator = Environment->getOSOperator();
                        const c8 *text = os_operator->getTextFromClipboard();
-                       if (text)
-                               prompt.input(narrow_to_wide(text));
+                       if (!text)
+                               return true;
+                       std::basic_string<unsigned char> str((const unsigned char*)text);
+                       prompt.input(std::wstring(str.begin(), str.end()));
                        return true;
                }
                else if(event.KeyInput.Key == KEY_KEY_X && event.KeyInput.Control)