473,569 Members | 2,438 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 8431
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_BYT E(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.co m 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_BYT E(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
3414
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. I'm wondering if something of such had been attempted in python, as in compiling X language into .pyc. I do not understand the schematics of .pyc...
9
9703
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) + (ord(c)<<16) + (ord(c)<<24)
3
7743
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 DB and display it onscreen. No matter which way I open the file, convert it to Unicode/leave it as is or what ever, I see all single bytes ok, but...
43
4760
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 character set specifies that each character such as 'b' or 'B' is an 8 bit character. So what's a multibyte character? Also how would you use the...
4
2409
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 unfortunate that i have to walk via System.String to do that. For instance, from an integer of value 123, i want:
0
7754
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: http://support.microsoft.com/default.aspx?scid=kb;en-us;170591 ). The problem I have is in order to perform a discovery/ping of an entire subnet...
5
5951
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 compression string ->(Unicode Conversion) byte -(Compression + Unicode Conversion) string
2
4355
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. The binary data is how they send numbers (they call it "Big Endian"). I only know at run time whether a byte is going to be text or binary (one of the...
17
10630
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 talking with another team -- codepage -- at the same time. I am more confused when I saw sometimes we need codepage parameter for wide character...
0
7618
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7679
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7983
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6287
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5223
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2117
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.