LWJGL
May 23, 2013, 16:45:34 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL is now using GitHub
 
   Home   Help Search Login Register  



Pages: [1] 2
  Print  
Author Topic: [FIXED] Unicode input  (Read 4207 times)
fellowusertoo
Newbie
*
Posts: 3


« on: July 23, 2011, 08:12:08 »

Keyboard.getEventCharacter() keeps returning ? whenever a unicode character is typed in.

Code:
char c = Keyboard.getEventCharacter();
System.out.println((int)c); // if this is a unicode character, it will keep printing 63 (which means ?)

char c = (char)29233; // Chinese letter "爱"
System.out.println((int)c); // in this case, it prints 29233 (which is correct).

How can I get unicode input (especially, Chinese characters)? Thanks in advance.
Logged
Matzon
Administrator
Demigod
*****
Posts: 2239



« Reply #1 on: July 23, 2011, 08:54:05 »

At this point, I think your best bet is to dig into the code, seeing as there are no unicode using devs.
Logged

fellowusertoo
Newbie
*
Posts: 3


« Reply #2 on: July 23, 2011, 17:56:39 »

I've found out that this is a bug in java. Microsoft's input method would just return ? for unicode characters. It even happens for TWL.
Only pure java... AWT or Swing input methods will work consistently for unicode input.

But I really need unicode input as my target application definitely requires handling of East Asian scripts (especially Chinese).

So, the only solution is to use AWT with LWJGL. But since that requires a rewrite on my own part
and JOGL has better support for binding with AWT (I like NEWT a lot). I've decided to use JOGL. A pity though, I really really liked LWJGL's simplicity.

Thanks for all the help. =D
Logged
princec
Nerdus Imperius
*****
Posts: 1870



WWW
« Reply #3 on: July 24, 2011, 06:32:45 »

LWJGL's AWT integration is, as far as I can see, every bit as good as JOGL's.

Cas Smiley
Logged

xand
Newbie
*
Posts: 2


« Reply #4 on: August 14, 2011, 17:49:36 »

Have the same problem, but with russian.
At english  system out prints
Code:
keycode 16  char q  charToInt 113
at russian
Code:
key 16  char ?  charToInt 233
but right is
Code:
key 16  char й  charToInt 1081

One good man told me
Quote
From reading LWJGL source code it could be related to this method which (incorrectly) only uses 8 bit of the 16 bit character code. This is the official Windows API documentation which says it's a 16 bit Unicode value.

It will be solved, or I need to find another way?

Logged
jediTofu
Prolific Timewaster
****
Posts: 280



« Reply #5 on: August 14, 2011, 21:41:18 »

LWJGL should also add support for WM_UNICHAR?

EDIT: also fix for WM_CHAR, would just be "(int)(wParam & 0xFFFF)"?
Logged

cool story, bro
spasi
Nerdus Imperius
*****
Posts: 752



WWW
« Reply #6 on: August 16, 2011, 15:24:08 »

The next nightly build will have unicode support on Windows. I was able to test it with Greek and Russian but had trouble with Chinese. Could you please check it out and let me know if it works?
Logged
Matzon
Administrator
Demigod
*****
Posts: 2239



« Reply #7 on: August 16, 2011, 21:57:56 »

nice work!, out of curiosity - how did you test this?
Just adding a new keyboard layout in windows or ?
Logged

spasi
Nerdus Imperius
*****
Posts: 752



WWW
« Reply #8 on: August 17, 2011, 02:06:28 »

Yes, I added new input languages and used the KeyboardTest to verify that it worked. Also used chcp <codepage> in the command prompt to be able to see non-english characters properly. Sys.alert and Display.setTitle have been tested with unicode text too.
Logged
Matzon
Administrator
Demigod
*****
Posts: 2239



« Reply #9 on: August 17, 2011, 03:01:18 »

chcp aha!
Logged

spasi
Nerdus Imperius
*****
Posts: 752



WWW
« Reply #10 on: August 19, 2011, 04:21:36 »

So, I did some more testing with chinese and it seems to work fine, except it's kinda useless in fullscreen mode. We need to expose IME events like this RFE suggests, so that people can build in-game components to handle such input. Something like Scaleform IME.
Logged
xand
Newbie
*
Posts: 2


« Reply #11 on: August 19, 2011, 12:23:47 »

I have tested it, it works fine. Thank You for your great work.
Logged
Socob
Newbie
*
Posts: 2


« Reply #12 on: August 20, 2011, 02:11:59 »

The Unicode support on Windows does indeed seem to work.
However, there are still problems on the Linux platform. Am I correct in assuming that this fix only addresses the issue on Windows? In particular, I have encountered the problem with the Display.setTitle() method. On Windows, if you do something like this:
Code:
Display.setTitle("éöäü")
it works fine, but on Linux, you get "éöäü" as the output, which indicates that LWJGL still assumes an 8-bit encoding. Is there any chance of this being solved as well?

(I am of course using the latest nightly build of LWJGL, and Linux Mint 11, if that matters.)
Logged
kappa
Administrator
Nerdus Imperius
*****
Posts: 1112



« Reply #13 on: August 20, 2011, 04:59:20 »

Added Unicode support to window titles on Linux, do test next nightly build of LWJGL 2.8 to confirm.
Logged
Socob
Newbie
*
Posts: 2


« Reply #14 on: August 20, 2011, 05:45:28 »

@kappa
Seems to work perfectly, thanks a lot!
Logged
Pages: [1] 2
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!