363,924 Members | 2575 Browsing Online
Community for Developers & IT Professionals
Bytes IT Community

How to get unicode value from aN UTF-8 character

globomike
P: n/a
globomike
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
Share this Question
Share on Google+
6 Replies


Jan M. Nelken
P: n/a
Jan M. Nelken
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

globomike
P: n/a
globomike
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

Jan M. Nelken
P: n/a
Jan M. Nelken
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

Serge Rielau
P: n/a
Serge Rielau
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
P: n/a
Serge Rielau
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

globomike
P: n/a
globomike
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

Post your reply

Help answer this question



Didn't find the answer to your DB2 Database question?

You can also browse similar questions: DB2 Database