Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1a390S-0003vQ-6w for pgsql-bugs@arkaria.postgresql.org; Sun, 29 Nov 2015 20:55:36 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1a390R-0002ws-6n for pgsql-bugs@arkaria.postgresql.org; Sun, 29 Nov 2015 20:55:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1a390Q-0002wl-Sm for pgsql-bugs@postgresql.org; Sun, 29 Nov 2015 20:55:34 +0000 Received: from ns1.hjp.at ([212.17.106.132] helo=zeno.hjp.at) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1a390N-0007U0-N7 for pgsql-bugs@postgresql.org; Sun, 29 Nov 2015 20:55:34 +0000 Received: by zeno.hjp.at (Postfix, from userid 1000) id 7E7094012; Sun, 29 Nov 2015 21:55:29 +0100 (CET) Date: Sun, 29 Nov 2015 21:55:29 +0100 From: "Peter J. Holzer" To: pgsql-bugs@postgresql.org Subject: Re: BUG #13785: Postgresql encoding screw-up Message-ID: <20151129205529.GB29654@hjp.at> References: <20151126121558.2760.44255@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="cmJC7u66zC7hs+87" Content-Disposition: inline In-Reply-To: <20151126121558.2760.44255@wrigleys.postgresql.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org --cmJC7u66zC7hs+87 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2015-11-26 12:15:58 +0000, ntpt@seznam.cz wrote: > Because there is no character 0x96 in latin2 , transcoder to utf8 does not > know the recipe how treat this chracter - and leave it "as is" producing > \u0096 character in output .=20 Actually, it does know. While the standard ISO-8859-2[1] only defines the printable characters, those are commonly combined with the control characters from ISO 6429, which does define a control code 0x96 (SPA). The unicode standard also defines two blocks of control characters and they have the same code points: 0x0D (CR) is translated to U+000D, 0x1B (ESC) is translated to U+001B and 0x96 (SPA) is translated to U+0096. So the "problem" here isn't that PostgreSQL doesn't know how to translate an ISO-8859-2 0x96 into unicode (if that was the case, it could reject it, forcing the user to fix the client configuration), but that it does know how to convert it and therefore does it - even if it is almost certainly wrong (when did you ever need an SPA character?). hp PS: I would write a script which fixes the wrong characters in situ.=20 That takes a bit of scripting, but: * You probably can't guarantee that all your clients are fixed,=20 so the problem may crop up again * So you want to be able to find out when that happens and fix it again without taking the db down. * A script like that can be expanded to fix other encoding errors, too (e.g. UTF-8 double-encoding, ISO-8859-2 vs. ISO-8859-1, ...) [1] I actually looked at ECMA-94, but they should be identical. --=20 _ | Peter J. Holzer | I want to forget all about both belts and |_|_) | | suspenders; instead, I want to buy pants=20 | | | hjp@hjp.at | that actually fit. __/ | http://www.hjp.at/ | -- http://noncombatant.org/ --cmJC7u66zC7hs+87 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIVAwUBVltmP/IOSFES/ihdAQLHiw//d0P4k5DW31EOPVsO0Y5XZKRZFuD41fHW 9I5itX9vU5lvR2ImhDPgJ9kNcUXeqRibeZJZahv5rFozasaejn6YwnF3wopmv0+T 4vVd/WGLFJDjR8MdDnkFe39REyoihda836vAy4iqso9Nm6T9rO9I9qivI6j3Ty0d WyNtT4JSqcyodIi9hCQpT+b6I1lNs1tR2TDYE3IzmFGPof+fOun1XOf0P/wy0phu tVGOSqLlCqGuKSmYJB2UiYVGwHp8TZMCwOkWfsrj0NswFRcumY8rTyHyotPoeQfG zMB4e+fbqBtX8wewBsjlgHCN5tAirLtjzOU2A6Ekou0hCVwJqe6W6Dg7F7jgLf4Y wGuK4zHj1iTF+5QS2esfVQeO6Kd2l/ZbHZT9CRGH+sJx7c4RqKdUVTpnbT9uythv /H0yxupTt4vHnI3ujGOeAFSOFgm01dnzJsISjLMIrxlSVbgTvauF08DRU9xltYHU nhGKaMo5LByglNc4zNrOD0tRCUCbniIG+f63lzkIuuBrqP1PypvNeXuIegzdznWO oBhzn0aS4NhabjNdAB0eNzBwAdm+OqHG/SdOl5gfbsJ00rshK9fxen89Zh+uiXmF C+uYT87e9bjohneVlSlx6DVQhHR+7MzNqH1nhzEL9FJgp3SLtJyewFrRkHIIs/kZ 2rtYJ/6g24U= =sOUV -----END PGP SIGNATURE----- --cmJC7u66zC7hs+87--