473,386 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 12769
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Svennglenn | last post by:
I'm working on a program that is supposed to save different information to text files. Because the program is in swedish i have to use unicode text for ÅÄÖ letters. When I run the following...
11
by: Patrick Van Esch | last post by:
Hello, I have the following problem of principle: in writing HTML pages containing ancient greek, there are two possibilities: one is to write the unicode characters directly (encoded as two...
4
by: webdev | last post by:
lo all, some of the questions i'll ask below have most certainly been discussed already, i just hope someone's kind enough to answer them again to help me out.. so i started a python 2.3...
0
by: Tim Northrup | last post by:
Help! We have DB2 V7.2 (fixpak 12) installed on Windows2003 Server, and the latest V7.2 client installed on another system. The DB2CODEPAGE on all systems is set to 1208, and the database was...
7
by: Csaba Gabor | last post by:
If I do alert(encodeURI(String.fromCharCode(250))); (in FF 1.5+ or IE6 on my winXP Pro) then I get: %C3%BA Now I was sort of expecting something like %u... (and a single (4 digit?) unicode hex...
1
by: willie | last post by:
>willie wrote: wrote:
18
by: Chameleon | last post by:
I am trying to #define this: #ifdef UNICODE_STRINGS #define UC16 L typedef wstring String; #else #define UC16 typedef string String; #endif ....
2
by: JimmyKoolPantz | last post by:
We purchased som software for encoding a barcode. We want to automate the process of converting a number to a readable barcode. However, I am having a few issues. The file that the barcode...
8
by: Yves Dorfsman | last post by:
Can you put UTF-8 characters in a dbhash in python 2.5 ? It fails when I try: #!/bin/env python # -*- coding: utf-8 -*- import dbhash db = dbhash.open('dbfile.db', 'w') db = u'☺'
5
by: Thierry | last post by:
Hello fellow pythonists, I'm a relatively new python developer, and I try to adjust my understanding about "how things works" to python, but I have hit a block, that I cannot understand. I...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.