• Post Reply Bookmark Topic Watch Topic
  • New Topic

formatting Japanese  RSS feed

 
Kevin Tysen
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working on a program which prints out a text file, taking long Strings and cutting them into smaller Strings and formatting them. As long as all the characters in the Strings are English letters, and punctuation, there is no problem. But when Japanese symbols are in the Strings, the formatting gets all messed up because although java considers a Japanese symbol to be one character, when it is printed out in a text file or printed on paper, the size of one Japanese symbol is the same size as two English letters. So what I need is some way for my program to distinguish between English letters and Japanese symbols.
Tasukete! (Help!)
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For letter only, a very straight forward way to do it would be like :


You could also try Apache Commons Lang library, which has a class called CharUtils with convenient methods like isAscii(char c).

Ganbatte ne. (good luck)
 
Kevin Tysen
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is Apache commons library? Where is it? I looked for the class CharUtils but I couldn't find it in the API.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://commons.apache.org/lang/
 
Kevin Tysen
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!