本文介绍了无法在Oracle中将eng字符转换为ascii的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在oracle中使用Asciistr方法,应该将给定的结构转换为ascii.阿拉伯字符已正确转换,但英语仍然相同,而在一些在线转换器中,我看到诸如1和2之类的数字已转换为0031和0032.这是我的方法:

 创建 替换过程 replace_ascii(test_var  in  varchar2,value退出varchar2)
开始
   选择替换(asciistr(test_var),'  \')
   插入 valueRet
    from 双重;
结束 replace_ascii; 



我目前正在以这种方式用期望值替换数字:

 选择 replace(替换(valueRet,'  1''  0031'),'  2''  0032')
 ....
插入 valueRet
来自 dual; 



但是我不想每次都使用替换"来返回正确的值.转换这些字符的最佳方法是什么?

1-> 0031

2-> 0032

A-> 0041

......

我在这里想念什么吗?请检查此链接 http://r12a.github.io/apps/conversion/并尝试转换英文数字和字母,然后检查最后一个标记的结果.

我尝试过的事情:

我尝试使用RAWTOHEX,但缺少一些字符,例如:1转换为0031的31 intead,A转换为41而不是0041 ....,并且阿拉伯字符转换不正确.


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
begin
   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 http://r12a.github.io/apps/conversion/ 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.

解决方案


这篇关于无法在Oracle中将eng字符转换为ascii的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 03:54