File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Trimming multi-byte spaces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Trimming multi-byte spaces" Watch "Trimming multi-byte spaces" New topic

Trimming multi-byte spaces

Ved Antani

Joined: Jan 05, 2003
Posts: 28
I want to write a simple function that can trim any (Any languagei.e., japanese, chinese ...etc) multibyte spaces....I want a generic method for this

Please help me !!!

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13024
If you want to determine whether or not a Unicode character is a "space" - look at the java.lang.Character static isWhitespace( char ch ) method.
Ved Antani

Joined: Jan 05, 2003
Posts: 28
Oh, I tried that but isWhitespace() does not recognize spaces which are multibyte( like in japanese langauge, Hiragana or Katakana characters are of 2 bytes and spaces are also of two bytes)

so it fails in telling me whether that character is a space or not...
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
Try Character.isSpaceChar().

"I'm not back." - Bill Harding, Twister
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
This may be dumb, but doesn't trim() do the job? It should remove all "white space" in the current character set?

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I agree. Here's the link:
subject: Trimming multi-byte spaces
It's not a secret anymore!