emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

string-width for emojis


From: Evgeny Zajcev
Subject: string-width for emojis
Date: Fri, 28 Jan 2022 19:32:47 +0300

I'm experiencing a bin unexpected behaviour with "string-width".

If I evaluate
  (insert "ABCDEF\n"
          "\x2734\xfe0f -> "
          (format "%d" (string-width "\x2734\xfe0f")))
directly in the scratch buffer, I'll get
  ABCDEF
  ✴️ -> 2
as output.  However, if I evaluate
  (with-current-buffer (get-buffer-create "*help2*")
    (erase-buffer)
    (insert "ABCDEF\n"
            "\x2734\xfe0f -> "
            (format "%d" (string-width "\x2734\xfe0f")))
    (display-buffer (current-buffer)))
I'll get
  ABCDEF
  ✴️ -> 1
as output.

Documentation states, that "Width is measured by how many columns it occupies on the screen."  I see visually that ✴️ occupies approximately 2 columns (see screenshot at http://lgarc.narod.ru/pics/emacs-string-width.png)

What is the correct use of `string-width` to always get 2 as width for the "\x2734\xfe0f" ?

Thanks

--
lg

reply via email to

[Prev in Thread] Current Thread [Next in Thread]