如何在PL/SQL中找到字符代码?

时间:2022-07-21 00:17:36

I want to find character code of particular character in string. For instance if I have a string

我想在字符串中找到特定字符的字符代码。例如,如果我有一个字符串。

"Hello"

“你好”

How do i find the character code of all or particular characters in the string.

如何查找字符串中所有或特定字符的字符代码。

I see that PL/SQL has a ASCII() and ASCIISTR() functions but I could not find any character related functions.

我看到PL/SQL有一个ASCII()和ASCIISTR()函数,但是找不到任何与字符相关的函数。

2 个解决方案

#1


4  

  create or replace function asciistr2(s IN varchar2)
  RETURN varchar2
  IS
    result varchar2(32767) := '';
  BEGIN
    FOR i IN 1..Length(s)
      LOOP
      dbms_output.put_line(ASCII(substr(s,i,1)));
      result := result || ASCII(substr(s,i,1));
      END LOOP;
      return result;
  END;


  Select asciistr2('HELLO') from dual

Result: 7269767679

结果:7269767679

dbms_output

dbms_output

 72
 69
 76
 76
 79

#2


1  

What exactly would you expect? Looking at your question, it seems to me that ASCII() would give you what you need, see this ASCII tutorial. You can loop

你到底想要什么?看到您的问题,在我看来ASCII()将提供您所需的信息,请参阅这个ASCII教程。你可以循环

Or are you referring to the Unicode value?

还是指Unicode值?

#1


4  

  create or replace function asciistr2(s IN varchar2)
  RETURN varchar2
  IS
    result varchar2(32767) := '';
  BEGIN
    FOR i IN 1..Length(s)
      LOOP
      dbms_output.put_line(ASCII(substr(s,i,1)));
      result := result || ASCII(substr(s,i,1));
      END LOOP;
      return result;
  END;


  Select asciistr2('HELLO') from dual

Result: 7269767679

结果:7269767679

dbms_output

dbms_output

 72
 69
 76
 76
 79

#2


1  

What exactly would you expect? Looking at your question, it seems to me that ASCII() would give you what you need, see this ASCII tutorial. You can loop

你到底想要什么?看到您的问题,在我看来ASCII()将提供您所需的信息,请参阅这个ASCII教程。你可以循环

Or are you referring to the Unicode value?

还是指Unicode值?