aspose file tools
The moose likes Java in General and the fly likes Bilingual support in Java Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Bilingual support in Java" Watch "Bilingual support in Java" New topic
Author

Bilingual support in Java

Ash Kondhalkar
Ranch Hand

Joined: Jun 14, 2006
Posts: 43
Hi,

We are supporting a bilingual application(English and Arabic). User can change some setting in a system tray so that he can enter data from keyboard in either of the language.
I want to restrict/validate user from entering English characters in Arabic field or vice versa.
Is there a way I can know what characters are getting inputed from keyboard? Are they English or Arabic? So that I can validate the input.

Kindly provide some suggestions.

Cheers
Ashwin
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35237
    
    7
English text would for the most part use ASCII or ISO-8859-1, so the characters entered would have values between 0 and 255. I'm not familair with how you enter Arabic text, but in a Java string it would have higher values (because of the Unicode encoding) - that's how you can tell them apart.


Android appsImageJ pluginsJava web charts
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


Is there a way I can know what characters are getting inputed from keyboard? Are they English or Arabic?

You are going to struggle to find a fool proof way of doing this. For example is this text English or Arabic: "78978789789" ? My point is you can guess based on the Unicode value of the String, but this will fail when encounter characters shared between English and Arabic.

I'm not sure why you need to stop English being entered when the application expects Arabic and viceversa. Can you explain why this is a problem?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Ash Kondhalkar
Ranch Hand

Joined: Jun 14, 2006
Posts: 43
Hi Ulf and Paul,

Thank you for your replies. Our customer's requirement is,user should only enter arabic in Arabic textfield and vice versa. So we need to do this.

Actually after going through JDK, I have found out the way! JDK provides a class "Character.UnicodeBlock", which provides constants for different langauges e.g ARABIC, BASIC_LATIN etc and also a method as "of". This method returns the unicode block of a character passed to it. So using this constant and a method I am in position to restrict user from entering non arabic characters in Arabi textfield!

Regards
Ashwin
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Bilingual support in Java
 
Similar Threads
Multilingual support by JTextField
Confused about currency character at the start of identifier
pageEncoding="UTF-8" in jsp
Dynamically convert english numbers to arabic in jsp
Unicode issue(for Arabic)