X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fbits%2FStringUtils.java;h=26d90a400577bf663f0b4550d1429de628c68b01;hb=218d18dbda14a7bf482d6c07bed66f16bcd6a6ba;hp=f5e2d47362a62e9c76bc0f731141a7cf43810d62;hpb=bfa37f3b2ef87d39c15fad7d565c00cbabd92acf;p=fanfix.git diff --git a/src/jexer/bits/StringUtils.java b/src/jexer/bits/StringUtils.java index f5e2d47..26d90a4 100644 --- a/src/jexer/bits/StringUtils.java +++ b/src/jexer/bits/StringUtils.java @@ -449,7 +449,8 @@ public class StringUtils { || ((ch >= 0xffe0) && (ch <= 0xffe6)) || ((ch >= 0x20000) && (ch <= 0x2fffd)) || ((ch >= 0x30000) && (ch <= 0x3fffd)) - // TODO: emoji / twemoji + // emoji + || ((ch >= 0x1f004) && (ch <= 0x1f9c0)) ) ) { return 2; @@ -466,8 +467,10 @@ public class StringUtils { */ public static int width(final String str) { int n = 0; - for (int i = 0; i < str.length(); i++) { - n += width(str.charAt(i)); + for (int i = 0; i < str.length();) { + int ch = str.codePointAt(i); + n += width(ch); + i += Character.charCount(ch); } return n; }