473,396 Members | 2,002 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,396 software developers and data experts.

how to perform muti byte to single byte conversion in DB2

HI,
Can anyone tell me how is a multi_byte to single byte and vice versa
conversion done in DB2.
It would be great even if someone can tell me how Oracle does it?
Oracle already has functions called to_single_byte and to_multi_byte
which convert a given multi byte character to single byte and vice
versa respectively.

thanks in advance
mailar
Nov 12 '05 #1
3 8405
mailar wrote:
HI,
Can anyone tell me how is a multi_byte to single byte and vice versa
conversion done in DB2.
It would be great even if someone can tell me how Oracle does it?
Oracle already has functions called to_single_byte and to_multi_byte
which convert a given multi byte character to single byte and vice
versa respectively.

thanks in advance
mailar

Mailar,

Do you mean between GRAPHIC and CHAR or between different encodings
within CHAR (and VARCHAR)?
Also Which platform are you on? In DB2 for LUW conversion is only done
implicitly between the client and the server. Only conversion to and
from BIT data can be done explicitly using the CAST() specification.
To cast from CHAR to GRAPHIC (and back) in a Unicode database usual cast
fucntions should work. GRAPHIC and CHAR are considered equivalent in
V8, btw)
In DB2 for zOS the CAST() specification can be used to cast to and from
Unicode as well using: CAST(c_db AS VARCHAR(10) CCSID UNICODE) or
CAST(c_uni AS VARCHAR(10) CCSID ASCII)
(DB2 zOS also supports a notation with SBCS and MBCS which I'm not very
familiar with. I believe it is legacy though)

I'm not familiar enough with DB2 for iSeries, but I think you can also
use CAST() and specify the CCSID by it's integer number. DB2 for iSeries
is leading the charge in this area.

Cheers
Serge
Nov 12 '05 #2
Hi Serge,
Thanks for your reply but actually I want this function to be used with
CHAR and VARCHAR data types.
Also, I am working on Windows(XP) platform.
The ORACLE implementation of TO_SINGLE_BYTE is something like this

Syntax
to_single_byte::=TO_SINGLE_BYTE(attribute)
Purpose
TO_SINGLE_BYTE returns attribute with all of its multibyte characters
converted
to their corresponding single-byte characters; attribute can be of data
type CHAR
or VARCHAR2. The value returned is in the same data type as attribute.
Any
multibyte characters in attribute that have no single-byte equivalents
appear in the
output as multibyte characters.
This function is useful only if your database character set contains
both single-byte
and multibyte characters.
Example
The following example illustrates going from a multibyte 'A' in UTF8 to
a single byte
ASCII 'A':
SELECT TO_SINGLE_BYTE( CHR(15711393)) FROM DUAL;
T
-
A
So, Could you tell me is ther a function or some feature in DB2 which
enables me to do this conversion.
Also, could you help me in going about the implementation of this
function in DB2.

Thanks and regards
mailar

Nov 12 '05 #3
ma****@gmail.com wrote:
Hi Serge,
Thanks for your reply but actually I want this function to be used with
CHAR and VARCHAR data types.
Also, I am working on Windows(XP) platform.
The ORACLE implementation of TO_SINGLE_BYTE is something like this

Syntax
to_single_byte::=TO_SINGLE_BYTE(attribute)
Purpose
TO_SINGLE_BYTE returns attribute with all of its multibyte characters
converted
to their corresponding single-byte characters; attribute can be of data
type CHAR
or VARCHAR2. The value returned is in the same data type as attribute.
Any
multibyte characters in attribute that have no single-byte equivalents
appear in the
output as multibyte characters.
This function is useful only if your database character set contains
both single-byte
and multibyte characters.
Example
The following example illustrates going from a multibyte 'A' in UTF8 to
a single byte
ASCII 'A':
SELECT TO_SINGLE_BYTE( CHR(15711393)) FROM DUAL;
T
-
A
So, Could you tell me is ther a function or some feature in DB2 which
enables me to do this conversion.
Also, could you help me in going about the implementation of this
function in DB2.

Thanks and regards
mailar

I have to confess ignorance.
To the best of my knowledge there is no matching function in DB2 for LUW.

Cheers
Serge
Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
by: Maurice LING | last post by:
Hi, I remembered reading a MSc thesis about compiling Perl to Java bytecodes (as in java class files). At least, it seems that someone had compiled scheme to java class files quite successfully....
9
by: franzkowiak | last post by:
Hello, I've read some bytes from a file and just now I can't interpret 4 bytes in this dates like a real value. An extract from my program def l32(c): return ord(c) + (ord(c)<<8) +...
3
by: hunterb | last post by:
I have a file which has no BOM and contains mostly single byte chars. There are numerous double byte chars (Japanese) which appear throughout. I need to take the resulting Unicode and store it in a...
43
by: Bill Cunningham | last post by:
I've been reading the C standard online and I'm puzzled as to what multibyte chars are. Wide chars I believe would be characters for languages such as cantonese or Japanese. I know the ASCII...
4
by: Dennis Myrén | last post by:
Hi. Is there a way to utilize the great primitive data type formatting routines available in .NET without working with strings? I want a byte directly rather than a string. I think it is...
0
by: Ed | last post by:
I've attached some VB.NET code I've hacked together (some taken from MS examples & newsgroup postings) that will perform a ping or IcmpSendEcho using the icmp.dll (see this for more info:...
5
by: jeremyje | last post by:
I'm writing some code that will convert a regular string to a byte for compression and then beable to convert that compressed string back into original form. Conceptually I have.... For...
2
by: DBuss | last post by:
OK, I'm reading a multicast socket. It attaches fine, reads fine, all of that. The problem is that while some of the data I get is normal text (ASCII String), some of it is Binary Integer. ...
17
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, Wide character and multi-byte character are two popular encoding schemes on Windows. And wide character is using unicode encoding scheme. But each time I feel confused when...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.