Re: badly calculated width of emoji in psql
John Naylor <john.naylor@enterprisedb.com>
From: John Naylor <john.naylor@enterprisedb.com>
To: Jacob Champion <pchampion@vmware.com>
Cc: "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>, "pavel.stehule@gmail.com" <pavel.stehule@gmail.com>, "laurenz.albe@cybertec.at" <laurenz.albe@cybertec.at>, "peter.eisentraut@enterprisedb.com" <peter.eisentraut@enterprisedb.com>, "michael@paquier.xyz" <michael@paquier.xyz>,
"horikyota.ntt@gmail.com" <horikyota.ntt@gmail.com>
Date: 2021-08-25T20:15:34Z
Lists: pgsql-hackers
On Tue, Aug 24, 2021 at 1:50 PM Jacob Champion <pchampion@vmware.com> wrote:
>
> Does there need to be any sanity check for overlapping ranges between
> the combining and fullwidth sets? The Unicode data on a dev's machine
> would have to be broken somehow for that to happen, but it could
> potentially go undetected for a while if it did.
It turns out I should have done that to begin with. In the Unicode data, it
apparently happens that a character can be both combining and wide, and
that will cause ranges to overlap in my scheme:
302A..302D;W # Mn [4] IDEOGRAPHIC LEVEL TONE MARK..IDEOGRAPHIC
ENTERING TONE MARK
{0x3000, 0x303E, 2},
{0x302A, 0x302D, 0},
3099..309A;W # Mn [2] COMBINING KATAKANA-HIRAGANA VOICED SOUND
MARK..COMBINING KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK
{0x3099, 0x309A, 0},
{0x3099, 0x30FF, 2},
Going by the above, Jacob's patch from July 21 just happened to be correct
by chance since the combining character search happened first.
It seems the logical thing to do is revert my 0001 and 0002 and go back to
something much closer to Jacob's patch, plus a big comment explaining that
the order in which the searches happen matters.
The EastAsianWidth.txt does have combining property "Mn" in the comment
above, so it's tempting to just read that (plus we could read just one file
for these properties). However, it seems risky to rely on comments, since
their presence and format is probably less stable than the data format.
--
John Naylor
EDB: http://www.enterprisedb.com
Commits
-
Extend collection of Unicode combining characters to beyond the BMP
- 5bc429aacb37 15.0 landed
-
Update display widths as part of updating Unicode
- bab982161e05 15.0 landed
-
Revert "Rename unicode_combining_table to unicode_width_table"
- 1563ecbc1be8 15.0 landed
-
Change mbbisearch to return the character range
- 78ab944cd4b9 15.0 landed