How to know the preferred display width (in columns) of Unicode characters?

后端 未结 5 2050
说谎
说谎 2020-12-23 18:10

In different encodings of Unicode, for example UTF-16le or UTF-8, a character may occupy 2 or 3 bytes. Many Unicode applications doesn\'t t

5条回答
  •  一向
    一向 (楼主)
    2020-12-23 18:21

    The Unicode property reflecting this concept is East_Asian_Width. It's not really reliable as a visual width in the context of general Unicode rendering, as non-Asian characters, combining characters etc. will fail to line up even in a monospaced font. (Your example certainly doesn't render lined-up for me.)

    Java does not have the built-in ability to read this property for characters (though Android's extension does). You can get it from ICU4J if you really need it.

提交回复
热议问题