Click here to Skip to main content
15,798,592 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am using Asciistr method in oracle which is supposed to convert given structure to ascii. Arabic characters are converted correctly but english are still the same while in some online converters I can see that numbers like 1 and 2 are converted to 0031 and 0032. Here is my method:

create or replace procedure replace_ascii(test_var in varchar2,valueRet out varchar2) is
   select  replace (asciistr(test_var), '\', null)
   into valueRet
   from dual;           
end replace_ascii;

I am currently replacing numbers with their expected value in this way:

select replace(replace (valueRet,'1','0031'),'2','0032') 
into valueRet
from dual;

But I don't want to use 'replace' each time to return the correct value. What is the best way to convert those characters?

1 --> 0031

2 --> 0032

A --> 0041


Am I missing something here? PLease check this link and try convert english numbers and letters, and check the result of the last tag.

What I have tried:

I tried to use RAWTOHEX but some characters are missed like: 1 is converted to 31 intead of 0031, A is converted to 41 instead of 0041 .... and arabic characters are converted incorrectly.
Updated 14-Oct-16 5:10am

1 solution

According to the documentation[^], the ASCIISTR function only converts non-ASCII characters.

English letters and the standard Arabic numerals (0-9) are all valid ASCII characters. Therefore, they won't be converted.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900