File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Internationalization query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Internationalization query" Watch "Internationalization query" New topic
Author

Internationalization query

shalu sharma
Ranch Hand

Joined: Sep 09, 2002
Posts: 51
Hi,

I am a novice in Internationalization API, i am working in a project which is to internationalize the site in multi-byte simplified chinese text.

I am trying to write a code for validation of a text area box where the user would be entering in chinese language. My code should check the maximum no of characters that a user can enter let's say the upper limit is fixed to 3000 chinese language characters.

Now I am not able to understand how can this be done, i mean which API in java supports such thing, does simply reading bytes solves this ?

I also have to perform a client side javascript validation for same. Does javascript supports internationalization ?

Thanks
Shalu
Stuart Ash
Ranch Hand

Joined: Oct 07, 2005
Posts: 637
If you textbox at the time of submission displays only the final chinese characters, then Java basically represents each one of these characters as a single char (of some unicode value up in the chinese region.) Thus, a simple, str.length() should work.

Let us know if this works.
[ December 20, 2005: Message edited by: Stuart Ash ]

ASCII silly question, Get a silly ANSI.
shalu sharma
Ranch Hand

Joined: Sep 09, 2002
Posts: 51
Originally posted by Stuart Ash:
If you textbox at the time of submission displays only the final chinese characters, then Java basically represents each one of these characters as a single char (of some unicode value up in the chinese region.) Thus, a simple, str.length() should work



Stuart,

yes my textarea would be displaying the final chinese characters only at the time of form submittal. I have one doubt, these simplified chinese characters takes more space as compared to english ie some of them takes 2 bytes some 3 bytes. Also when I write these charcters on my text area i am able to write about 30 characters on a avergae per line.

So does it mean that I have to increase the rows and cols of the text area as the upper limit should be same as that of english character. I just wanted to understand is this the approach being followed in other chinese sites also. As a matter of fact, I looked at yahoo china, but there the look and feel is almost the same as yahoo india or yahoo US.

Does u have any idea how can I validate the chinese character in javascript, let's say I do not want the chinese equivalent of ; and ! not to be entered by the user. how can this be achieved ?

I hope I haven't confused you..

Thanks
Shalu
shalu sharma
Ranch Hand

Joined: Sep 09, 2002
Posts: 51
Hey no replies .. still waiting ..
Stuart Ash
Ranch Hand

Joined: Oct 07, 2005
Posts: 637
Originally posted by shalu sharma:



Stuart,

yes my textarea would be displaying the final chinese characters only at the time of form submittal. I have one doubt, these simplified chinese characters takes more space as compared to english ie some of them takes 2 bytes some 3 bytes. Also when I write these charcters on my text area i am able to write about 30 characters on a avergae per line.

So does it mean that I have to increase the rows and cols of the text area as the upper limit should be same as that of english character. I just wanted to understand is this the approach being followed in other chinese sites also. As a matter of fact, I looked at yahoo china, but there the look and feel is almost the same as yahoo india or yahoo US.


I hope I haven't confused you..

Thanks
Shalu


I hope too

"bytes" don't equate to "space." A single chinese character, say 中, will need two or three bytes in the encoding system, but will take up just one "unit of space" on a PC display. That is if you write 5 chinese characters and five Roman characters (abc...) on two successive lines using a monospace font, they would occupy the same space.

So, you decide whether to look at character count or byte count - they are different.
Stuart Ash
Ranch Hand

Joined: Oct 07, 2005
Posts: 637
I am trying to demonstrate the char spacing example here, not sure if it displays on your PC.




The third one is Japanese.
Stuart Ash
Ranch Hand

Joined: Oct 07, 2005
Posts: 637
Originally posted by Stuart Ash:
I am trying to demonstrate the char spacing example here, not sure if it displays on your PC.




The third one is Japanese.



I think I am wrong, about the character spacing. Any Chinese person here to add light?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Internationalization query
 
Similar Threads
Need Unicode convertor software
text area character limit code without trimming
Internationalization on J2ME
string delimiter
Non-English characters in Java code