Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gInnb-0001uh-KP for pgsql-bugs@arkaria.postgresql.org; Sat, 03 Nov 2018 04:44:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gInnZ-0004WQ-BW for pgsql-bugs@arkaria.postgresql.org; Sat, 03 Nov 2018 04:44:37 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gInnZ-0004WJ-1t for pgsql-bugs@lists.postgresql.org; Sat, 03 Nov 2018 04:44:37 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gInnV-0000AQ-Vc for pgsql-bugs@lists.postgresql.org; Sat, 03 Nov 2018 04:44:35 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id wA34iUq3002102; Sat, 3 Nov 2018 00:44:30 -0400 From: Tom Lane To: h8mastre@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15476: Problem on show_trgm with 4 byte UTF-8 characters In-reply-to: <15476-4314f480acf0f114@postgresql.org> References: <15476-4314f480acf0f114@postgresql.org> Comments: In-reply-to =?utf-8?q?PG_Bug_reporting_form?= message dated "Thu, 01 Nov 2018 02:39:20 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <2100.1541220270.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 03 Nov 2018 00:44:30 -0400 Message-ID: <2101.1541220270@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk =3D?utf-8?q?PG_Bug_reporting_form?=3D writes: > On Encoding=3DUTF-8 database, try: > SELECT show_trgm('123'); > =E2=86=92 OK > SELECT show_trgm('=E6=97=A5=E6=9C=AC=E8=AA=9E'); > =E2=86=92 probably OK. > SELECT show_trgm('=F0=9F=94=8D'); > ERROR: invalid multibyte character for locale > HINT: The server's LC_CTYPE locale is probably incompatible with the > database encoding. > SQL state: 22021 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. > Please check: t_isdigit, t_isspace, t_isalpha, and t_isprint. > https://github.com/postgres/postgres/blob/322548a8abe225f2cfd6a48e07b99e= 2711d28ef7/src/backend/tsearch/ts_locale.c#L35 > char2wchar 4th parameter should take number of input bytes. However they > pass character count. > int clen =3D pg_mblen(ptr); > ... > char2wchar(character, 2, ptr, clen, mylocale); Huh? pg_mblen returns the number of bytes in a multibyte character, so this looks fine to me. regards, tom lane