Re: Question on inserting non-ascii strings

Поиск
Список
Период
Сортировка
От Steven Lembark
Тема Re: Question on inserting non-ascii strings
Дата
Msg-id 20090514193941.7346f7ef@bird.wrkhors.com
обсуждение исходный текст
Ответ на Re: Question on inserting non-ascii strings  (Sam Mason <sam@samason.me.uk>)
Ответы Re: Question on inserting non-ascii strings  (Sam Mason <sam@samason.me.uk>)
Список pgsql-general
> Which "warnings" are you talking about?  I thought you said you had
> plain SQL working OK, but were struggling to pass parameters containing
> UTF-8 encoded characters.
>
> Are you sure that your Perl code is passing the string encoded as UTF8?

Excellent point: Perl will only pass through the
converted UTF8, if I remember to convert it from
unicode!

The earlier version of the database used SQL_ASCII
and took the unicode byte as-is with a nastygram
about trans-ascii byte -- which led me down the
path of E'xxx'. While trying to make that work I'd
accidentally fat-figered out the utf8 conversion
attempting to comment it out.

Character   Unicode Code    Unicode Name                      UTF Encoding

(from http://www.nlm.nih.gov/databases/dtd/medline_character_database.html#notes)

    use utf8;

    x $c = "\x{F8}"

    x utf8::encode $c;

    x $c
    0  'ø'           <-- UTF8 for a slashed o.

    $sth->execute( $c )

    x $d = $dbh->selectall_arrayref( 'select * from foo' );
    0  ARRAY(0x18ef0d0)
       0  ARRAY(0x18cc1e8)
          0  'ø'     <-- bytes in correct order

    x  utf8::decode $d->[0][0]
    DB<106>  x $d
    0  ARRAY(0x18ef0d0)
       0  ARRAY(0x18cc1e8)


I'm still not sure whether using UTF8 or unicode is
the best way going forward, but will probably stick
with UTF8 in case I have to deal with any offball
character sets.

thanx

В списке pgsql-general по дате отправления:

Предыдущее
От: Dave Page
Дата:
Сообщение: Re: Where is pg_dump?
Следующее
От: Sam Mason
Дата:
Сообщение: Re: Question on inserting non-ascii strings