File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes check for characters and spaces using ASCII fails for other languages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "check for characters and spaces using ASCII fails for other languages" Watch "check for characters and spaces using ASCII fails for other languages" New topic
Author

check for characters and spaces using ASCII fails for other languages

koushik Rock
Greenhorn

Joined: Dec 07, 2010
Posts: 6
If we allow only chars and spaces we usually compare ASCII values in javascript. But what if we support multiple language, the check fails to work. Please advise me on this, any other way considering other languages too...
The javascript we usually use is like that -->
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18141
    
    8

I assume that when you said "chars and spaces" you really meant "letters and spaces"?

Well, if you want to extend that algorithm to all letters then you're going to have to go through the Unicode code charts and find out which scripts you want to support letters from. (Hint: there's a lot of scripts covered by Unicode.)

Or you could look for code from somebody else who has already solved the problem. But if it were me I would be reviewing why somebody had required "only letters and spaces" in the first place.
 
Consider Paul's rocket mass heater.
 
subject: check for characters and spaces using ASCII fails for other languages
 
Similar Threads
Please help break our java parser
Question on javascript Confirm Button for jsf or icefaces equivalent
byte array
Words with capital letters
How do you check if a user is going back to the previous page (history.back)?