Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Euro sign not displayed properly when fetched from DB
On 7 Oct 2006 07:45:03 -0700, "Raga" <raaga.t_at_gmail.com> wrote:
>I stored the euro sign (¤ ) (press alt+0 1 2 8 on Windows to get that
>sign) in an Oracle database table in varchar2 type column. when I do
>'select * from table_euro;', I get the euro sign displayed properly in
>SQL prompt.
>
>SQL> select * from table_euro
>2 /
>
>NAME
>--------------------
>¤
>
>Now, I programatically read it using Java Resultset object, but it
>displays as Ç (which is Alt + 1 2 8 in key press). This' how I fetch
>it programmatically:
>
>dbStatement = dbCon.createStatement(ResultSet.TYPE_FORWARD_ONLY,
>ResultSet.CONCUR_READ_ONLY);
>dbDataReader = dbStatement.executeQuery(query);
>....
>while(until result set is read fully)
>{
>Object fieldData = dbDataReader.getObject(fieldIndex);
>System.out.println(fieldData);
>
>}
>
>For the euro sign, the above prints Ç . Why is that? Can anyone please
>throw some light on it?
To know what's happening, you need to know:
(1) Your database character set.
(2) What NLS_LANG (environment variable) was set to when you inserted the character.
(3) What's actually been stored in the database; use something like:
select dump(name) from table_euro;
(4) What NLS_LANG is when you fetched the character.
The key to keeping character data encoded correctly is to ensure you know exactly what encoding it's in, and possibly being converted to, throughout its entire lifetime.
Euro is a particularly fun character because it's in different places in different character set encodings (and not even present in iso-8859-1 which is a very common encoding).
-- Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis toolReceived on Sat Oct 07 2006 - 09:56:21 CDT
![]() |
![]() |