Re: psql weird behaviour with charset encodings

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: hernan gonzalez <hgonzalez(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: psql weird behaviour with charset encodings
Date: 2010-05-08 13:53:13
Message-ID: 2734.1273326793@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

hernan gonzalez <hgonzalez(at)gmail(dot)com> writes:
> Sorry about a error in my previous example (mixed width and precision).
> But the conclusion is the same - it works on bytes:

This example works like that because it's running in C locale always.
Try something like this:

#include<stdio.h>
#include<locale.h>

int main () {
char s[] = "ni\xc3qo"; /* 5 bytes , not valid utf8 */

setlocale(LC_ALL, "");
printf("|%.*s|\n",3,s);
return 0;
}

I get different (and undesirable) effects depending on LANG.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Paulo moraes 2010-05-08 16:32:48 Invitation to connect on LinkedIn
Previous Message Selena Deckelmann 2010-05-08 13:46:06 Lightning Talks for PgCon! Submit yours today.

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2010-05-08 14:01:06 Re: possible memory leak with SRFs
Previous Message Selena Deckelmann 2010-05-08 13:46:06 Lightning Talks for PgCon! Submit yours today.