MySQL Forums
Forum List  »  General

Re: Convert Char to Hex (EBCDIC)
Posted by: Udhayakumar Sankaran
Date: August 23, 2018 02:00AM

Hi Peter,
Thank for your response. I had posted a reply last week but not sure why it was not there.

Select hex("ABCDE"); --> 4142434445
Whereas I am expecting result as C1C2C3C4C5

Just to brief my requirement: I want to convert CHAR to EBCDIC binary format (ex: "ABCDE" to be converted to "1100000111000010110000111100010011000101")

Upon analysing a bit found that I need to follow two step to achive this
1. Convert CHAR to Hex EBCDIC (ABCDE -> C1C2C3C4C5)
2. Convert Hex to Binary (C1C2C3C4C5 -> 1100000111000010110000111100010011000101)

Got the below function to perform#2 , but unable to get function to perform#1
Select LPAD(CONV('C1C2C3C4C5', 16, 2), LENGTH('C1C2C3C4C5')*4, '0')

Options: ReplyQuote


Subject
Written By
Posted
Re: Convert Char to Hex (EBCDIC)
August 23, 2018 02:00AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.