Re: [GENERAL] psql weird behaviour with charset encodings - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [GENERAL] psql weird behaviour with charset encodings
Date
Msg-id 2734.1273326793@sss.pgh.pa.us
Whole thread Raw
In response to Re: [GENERAL] psql weird behaviour with charset encodings  (hernan gonzalez <hgonzalez@gmail.com>)
Responses Re: [GENERAL] psql weird behaviour with charset encodings
List pgsql-hackers
hernan gonzalez <hgonzalez@gmail.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

pgsql-hackers by date:

Previous
From: Selena Deckelmann
Date:
Subject: Lightning Talks for PgCon! Submit yours today.
Next
From: Tom Lane
Date:
Subject: Re: possible memory leak with SRFs