• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Accept unicode Input from user in java

 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All
I am designing a multilingual desktop application. My Requirement is, i want to allow your to enter unicode input in application.
Currently i am using one external application called "Baraha Script" for input. But i wanted to create my own java code which will allow user to enter the data in selected language.
Can anyone help me for the same, or at least give a pointer for studies?

Thanks.
Mahesh
 
Marshal
Posts: 80767
488
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch

Have you found the appropriate page in the Unicode charts? Can you get it to print on a JOptionPane?I chose Hebrew because it has few letters (22) which form a continuous series so you won't get any rectangles in your output.
 
Mahesh Kedari
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks alot Campbell for reply, but the code that you have posted is for displaying unicode data in java.
I wanted to accept the input from user.
 
Campbell Ritchie
Marshal
Posts: 80767
488
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds like the sort of thing you can use a JOptionPane input dialog, or a JTextField, or similar for. Have you tried any of them?
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the same issue. Copy&paste 'special' unicodes into an JInputField in my application leads to squares. Doing the same with a test snippet works fine. Any idea why this happens?

You can try it with युनिकोड


Edit:
Windows7 64bit german: c&p युनिकोड fails, c&p ныя сымбалі works fine
Mint13 Cinnamon german 32bit: c&p युनिकोड works fine, c&p ныя сымбалі works fine, too

 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It may be that default font being used by JOptionPane can't display those characters. I just pasted them into a JTextField in an application I wrote to handle multiple languages and it worked for me. See below:
text.png
[Thumbnail for text.png]
Language Test
 
Oliver Brocker
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your reply. You're probably right. It very likely depends on the fonts installed on the client PC.
So I don't think it's an issue of my application, and unfortunately there's nothing I could do.

Edit:
I think about it and there something I do not get. If it's a font related issue, why are Firefox, MS Word, MS Notepad and other applications on the Client PC able to display the characters, but my application is not?
 
Tony Docherty
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Possibly because the font that the Java option pane is using is a logical font and logical fonts get mapped to a physical font on your system. It maybe those applications are using a font which supports that character set but the logical font is being mapped to font(s) (I seem to remember it maps to multiple fonts to get a greater range of possible character sets) that does not support the required characters.

To test this write a simple gui app with a text field which you set to use a physical font which you know works (ie the one notepad is using). Then cut and paste the text from notepad to your text field.
 
Oliver Brocker
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A good idea and I've tried it and now I'm totally confused. The same font is working in MS Notepad, but not in JTextField.
font.png
[Thumbnail for font.png]
Font test
 
Oliver Brocker
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any help would be greatly appreciated
 
Sheriff
Posts: 28413
102
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you looked at all the fonts supported by your Java implementation to see if "Lucida Console" is one of them?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic