Re: [GENERAL] psql weird behaviour with charset encodings

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: hgonzalez(at)gmail(dot)com
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [GENERAL] psql weird behaviour with charset encodings
Date: 2010-05-09 01:24:45
Message-ID: 18815.1273368285@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

hgonzalez(at)gmail(dot)com writes:
> http://sources.redhat.com/bugzilla/show_bug.cgi?id=649

> The last explains why they do not consider it a bug:

> ISO C99 requires for %.*s to only write complete characters that fit below
> the
> precision number of bytes. If you are using say UTF-8 locale, but ISO-8859-1
> characters as shown in the input file you provided, some of the strings are
> not valid UTF-8 strings, therefore sprintf fails with -1 because of the
> encoding error. That's not a bug in glibc.

Yeah, that was about the position I thought they'd take.

So the bottom line here is that we're best off to avoid %.*s because
it may fail if the string contains data that isn't validly encoded
according to libc's idea of the prevailing encoding. I think that
means the patch I committed earlier is still a good idea, but the
comments need a bit of adjustment. Will fix.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2010-05-09 02:19:08 Re: psql weird behaviour with charset encodings
Previous Message Tom Lane 2010-05-09 01:03:41 Re: Query that produces index information for a Table

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2010-05-09 02:19:08 Re: psql weird behaviour with charset encodings
Previous Message Tom Lane 2010-05-09 00:57:26 Re: max_standby_delay considered harmful