From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Greg Stark <stark(at)mit(dot)edu> |
Cc: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Unicode grapheme clusters |
Date: | 2023-01-21 18:12:57 |
Message-ID: | Y8wrKdVl/HpKDYrP@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Sat, Jan 21, 2023 at 12:37:30PM -0500, Bruce Momjian wrote:
> Well, as one of the URLs I quoted said:
>
> This is by design. wcwidth() is utterly broken. Any terminal or
> terminal application that uses it is also utterly broken. Forget
> about emoji wcwidth() doesn't even work with combining characters,
> zero width joiners, flags, and a whole bunch of other things.
>
> So, either we have to find a function in the library that will do the
> looping over the string for us, or we need to identify the special
> Unicode characters that create grapheme clusters and handle them in our
> code.
I just checked if wcswidth() would honor graphene clusters, though
wcwidth() does not, but it seems wcswidth() treats characters just like
wcwidth():
$ LANG=en_US.UTF-8 grapheme_test
wcswidth len=7
bytes_consumed=4, wcwidth len=2
bytes_consumed=4, wcwidth len=2
bytes_consumed=3, wcwidth len=0
bytes_consumed=3, wcwidth len=1
bytes_consumed=3, wcwidth len=0
bytes_consumed=4, wcwidth len=2
C test program attached. This is on Debian 11.
--
Bruce Momjian <bruce(at)momjian(dot)us> https://momjian.us
EDB https://enterprisedb.com
Embrace your flaws. They make you human, rather than perfect,
which you will never be.
Attachment | Content-Type | Size |
---|---|---|
grapheme_test.c | text/x-csrc | 547 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2023-01-21 18:17:27 | Re: Unicode grapheme clusters |
Previous Message | Bruce Momjian | 2023-01-21 17:37:30 | Re: Unicode grapheme clusters |