Re: BUG #15476: Problem on show_trgm with 4 byte UTF-8 characters
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: kenji uno <h8mastre@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Date: 2018-11-03T17:03:20Z
Lists: pgsql-bugs
kenji uno <h8mastre@gmail.com> writes: >> I failed to reproduce this on a Linux machine. It looks to me like the >> problem is that Windows' MultiByteToWideChar doesn't think that UTF8 >> character is valid. > I'm just wondering why my issue occurs only on Windows. > But I knew why: char2wchar's tolen requires +1 output buffer size, due to > null-termination. Oooh ... the problem, effectively, is that the ts_locale.c functions are expecting to get back UTF32 but what they'll actually get on Windows is UTF16. So if the given character is outside the BMP range, char2wchar needs to produce a surrogate pair, which there's not room for given that the output buffer can only hold 1 wchar_t plus trailing null. Then the other problem is that the Windows-Unicode code path in char2wchar just fails for an undersized output buffer, which you would not expect from its documentation. And it fails with a misleading error message, too. I'll see what I can do about this --- thanks for the report! regards, tom lane
Commits
-
Make ts_locale.c's character-type functions cope with UTF-16.
- f7ba6e951a12 10.6 landed
- bf4a9562e8b9 11.1 landed
- 981dc2baa8e0 12.0 landed
- 73dbaed93b46 9.6.11 landed
- 6e6092989fbb 9.5.15 landed
- 33c697e9d4a0 9.3.25 landed
- 0ae902e39ed8 9.4.20 landed
-
Update obsolete comments
- 322548a8abe2 11.0 cited