East Asian Widthã¨ç©å½¢ç·¨é
Eclipseã«ã¯ICU4Jããã©ã°ã¤ã³ã¨ãã¦çµã¿è¾¼ã¾ãã¦ãããããªã®ã§ãç©å½¢ç·¨éã®ã«ã©ã è¨ç®ã«East Asian Widthã使ãããã«ãã¦ã¿ã¾ãããåã ã®æåå¹ ã®è¨ç®ã¯ã以ä¸ã®ããã«ãã¦ãã¾ãã
public final class CharacterUtils { private CharacterUtils() {} private static List<String> EAST_ASIAN_LANGS = Arrays.asList("ja", "vi", "kr", "zh"); public static int getWidth(int codePoint) { return getWidth(codePoint, Locale.getDefault()); } public static int getWidth(int codePoint, Locale locale) { if(locale == null) { throw new NullPointerException("locale is null"); } int value = UCharacter.getIntPropertyValue(codePoint, UProperty.EAST_ASIAN_WIDTH); switch(value) { case UCharacter.EastAsianWidth.NARROW: case UCharacter.EastAsianWidth.NEUTRAL: case UCharacter.EastAsianWidth.HALFWIDTH: return 1; case UCharacter.EastAsianWidth.FULLWIDTH: case UCharacter.EastAsianWidth.WIDE: return 2; case UCharacter.EastAsianWidth.AMBIGUOUS: if(EAST_ASIAN_LANGS.contains(locale.getLanguage())) { return 2; } else { return 1; } default: return 1; } } }
åé¡ã®AMBIGUOUSã®ã¨ããã¯ããã±ã¼ã«ã®è¨èªãCJKVã®ããããã®å ´åã¯å ¨è§ã¨ãã¾ããã