469,352 Members | 2,154 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

How to get unicode value from aN UTF-8 character

Hi,

I would like to gtet the unicode value of an character stored in a DB2
UTF-8 database.

For example:
having the german character "" (a with two dots above)
the Unicode value would be '00E4' and this is what I need.
Using the hex function will returen C3A4 - so I can not use it for my
needs.

The technique I am looking for should work for ALL charcters defined
in the unicode standard.....
Thanks in advance for any help

kind regards
globomike

Jun 6 '07 #1
6 12333
globomike wrote:
Hi,

I would like to gtet the unicode value of an character stored in a DB2
UTF-8 database.

For example:
having the german character "" (a with two dots above)
the Unicode value would be '00E4' and this is what I need.
Using the hex function will returen C3A4 - so I can not use it for my
needs.
Ken Lunde's book CJKV Information Processing (O'Reilly published it:
ISBN 1-56592-224-7) has table 4-54 which explains how to convert from
UCS2 to UTF-8 bit array.

Your 00E4 UCS-2 code point (in binary 1110 0100) thus transforms to (in
binary) 110 xxxxx 10 xxxxxx:

110 0001110 10 0100

which when grouped in 4 bits /nibble is:

1100 0011 1010 0100

C 3 A 4

which is what your hex function is returning (correctly).
Jan M. Nelken
Jun 6 '07 #2
On 6 Jun., 21:04, "Jan M. Nelken" <Unknown.U...@Invalid.Domainwrote:
globomike wrote:
Hi,
I would like to gtet the unicode value of an character stored in a DB2
UTF-8 database.
For example:
having the german character "" (a with two dots above)
the Unicode value would be '00E4' and this is what I need.
Using the hex function will returen C3A4 - so I can not use it for my
needs.

Ken Lunde's book CJKV Information Processing (O'Reilly published it:
ISBN 1-56592-224-7) has table 4-54 which explains how to convert from
UCS2 to UTF-8 bit array.
Hi Jan,

thanks for that input but this is not really the SQL solution I wanted
to see -
there is no funcztion for it and also not for the binary display of
the code.
I think a UDF or Stored Proc will be the only solution -
would be nice if the code would be available for free somewhere (for
example developer works....)

Thanks
globomike
Your 00E4 UCS-2 code point (in binary 1110 0100) thus transforms to (in
binary) 110 xxxxx 10 xxxxxx:

110 0001110 10 0100

which when grouped in 4 bits /nibble is:

1100 0011 1010 0100

C 3 A 4

which is what your hex function is returning (correctly).

Jan M. Nelken

Jun 8 '07 #3
globomike wrote:
Hi Jan,

thanks for that input but this is not really the SQL solution I wanted to see -
there is no function for it and also not for the binary display of the code.
I think a UDF or Stored Proc will be the only solution - would be nice if the code
would be available for free somewhere (for example developer works....)
It is available for free: feel free to write one :-)

I will look around though ...
Jan M. Nelken
Jun 8 '07 #4
HEX(CAST(<graphic-charcterAS VARCHAR(3)))
should do it in a unicode database....

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Jun 8 '07 #5
Serge Rielau wrote:
HEX(CAST(<graphic-charcterAS VARCHAR(3)))
should do it in a unicode database....
Actually it appears you want the opposite... just run it backwards :-)
HEX(CAST('A' AS GRAPHIC(1)))

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Jun 8 '07 #6
On 8 Jun., 17:10, Serge Rielau <srie...@ca.ibm.comwrote:
Serge Rielau wrote:
HEX(CAST(<graphic-charcterAS VARCHAR(3)))
should do it in a unicode database....

Actually it appears you want the opposite... just run it backwards :-)
HEX(CAST('A' AS GRAPHIC(1)))

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

Hi Serge,

thanks a lot - you are a hero - this is exactly what I need !

kind regards
Michael

Jun 8 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

19 posts views Thread by Svennglenn | last post: by
11 posts views Thread by Patrick Van Esch | last post: by
4 posts views Thread by webdev | last post: by
7 posts views Thread by Csaba Gabor | last post: by
1 post views Thread by willie | last post: by
18 posts views Thread by Chameleon | last post: by
8 posts views Thread by Yves Dorfsman | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.