Re: UTF8 encoding and non-text data types - Mailing list pgsql-sql

From Steve Midgley
Subject Re: UTF8 encoding and non-text data types
Date
Msg-id 20080114045209.8C53E2E2D51@postgresql.org
Whole thread Raw
In response to UTF8 encoding and non-text data types  ("Medi Montaseri" <montaseri@gmail.com>)
List pgsql-sql
At 02:22 PM 1/13/2008, pgsql-sql-owner@postgresql.org wrote:
>Date: Sat, 12 Jan 2008 14:21:00 -0800
>From: "Medi Montaseri" <montaseri@gmail.com>
>To: pgsql-sql@postgresql.org
>Subject: UTF8 encoding and non-text data types
>Message-ID: 
><8078a1730801121421l1c9b90c1lc65d36cf6e752a6f@mail.gmail.com>
>
>I understand PG supports UTF-8 encoding and I have sucessfully 
>inserted
>Unicode text into columns. I was wondering about other data types such 
>as
>numbers, decimal, dates
>
>That is, say I have a table t1 with
>create table t1 { name text, cost decimal }
>I can insert UTF8 text datatype into this table with no problem
>But if my application attempts to insert numbers encloded in UTF8, 
>then I
>get wrong datatype error
>
>Is the solution for the application layer (not database) to convert 
>the
>non-text UTF8 numbers to ASCII and then insert it into database ?
>
>Thanks
>Medi

Hi Medi,

I have only limited experience in this area, but it sounds like you 
sending your numbers as strings? In your example:

>create table t1 { name text, cost decimal };

insert into t1 (name, cost) values ('name1', '1');

I can't think of how else you're sending numeric values as UTF8? I know 
that Pg will accept numbers as strings and convert internally (that has 
worked for me in some object relational environments where I don't 
choose to cope with data types), but I think it would be better if you 
simply didn't send your numeric data in quotations, whether as UTF8 or 
ASCII. If you don't have control over this layer (that quotes your 
values), then I'd say converting to ASCII would solve the problem. But 
better to convert to numeric and not ship quoted strings at all.

I may be totally off-base and missing something fundamental and I'm 
very open to correction (by anyone), but that's what I can see here.

Best regards,

Steve



pgsql-sql by date:

Previous
From: "Medi Montaseri"
Date:
Subject: UTF8 encoding and non-text data types
Next
From: "Marc Mamin"
Date:
Subject: Re: SQL question: Highest column value of unique column pairs