This week's book giveaway is in the HTML/CSS/JavaScript forum.
We're giving away four copies of Practical SVG and have Chris Coyier on-line!
See this thread for details.
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Trimming multi-byte spaces

 
Ved Antani
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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 !!!

Ved
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Bill
 
Ved Antani
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try Character.isSpaceChar().
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This may be dumb, but doesn't trim() do the job? It should remove all "white space" in the current character set?
 
Who among you feels worthy enough to be my best friend? Test 1 is to read this tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!