通过pl / sql将字符串转换为代码符号

时间:2014-05-19 17:03:59

标签: oracle utf-8 plsql

我必须使用pl / sql将本地语言的字符串转换为UTF代码符号(我认为它是UTF代码符号)。

例如,初始字符串为:“шт”,目标字符串应为шт

有什么想法吗? 谢谢。

2 个答案:

答案 0 :(得分:2)

将所有Win-1251符号转换为UTF:
冗长,但不依赖于服务器代码页:-)

S := REPLACE(S,'Ђ','Ђ');
S := REPLACE(S,'Ѓ','Ѓ');
S := REPLACE(S,'‚','‚');
S := REPLACE(S,'ѓ','ѓ');
S := REPLACE(S,'„','„');
S := REPLACE(S,'…','…');
S := REPLACE(S,'†','†');
S := REPLACE(S,'‡','‡');
S := REPLACE(S,'€','€');
S := REPLACE(S,'‰','‰');
S := REPLACE(S,'Љ','Љ');
S := REPLACE(S,'‹','‹');
S := REPLACE(S,'Њ','Њ');
S := REPLACE(S,'Ќ','Ќ');
S := REPLACE(S,'Ћ','Ћ');
S := REPLACE(S,'Џ','Џ');
S := REPLACE(S,'ђ','ђ');
S := REPLACE(S,'‘','‘');
S := REPLACE(S,'’','’');
S := REPLACE(S,'“','“');
S := REPLACE(S,'”','”');
S := REPLACE(S,'•','•');
S := REPLACE(S,'–','–');
S := REPLACE(S,'—','—');
S := REPLACE(S,'™','™');
S := REPLACE(S,'љ','љ');
S := REPLACE(S,'›','›');
S := REPLACE(S,'њ','њ');
S := REPLACE(S,'ќ','ќ');
S := REPLACE(S,'ћ','ћ');
S := REPLACE(S,'џ','џ');
S := REPLACE(S,'Ў','Ў');
S := REPLACE(S,'ў','ў');
S := REPLACE(S,'Ј','Ј');
S := REPLACE(S,'Ґ','Ґ');
S := REPLACE(S,'Ё','Ё');
S := REPLACE(S,'Є','Є');
S := REPLACE(S,'Ї','Ї');
S := REPLACE(S,'І','І');
S := REPLACE(S,'і','і');
S := REPLACE(S,'ґ','ґ');
S := REPLACE(S,'ё','ё');
S := REPLACE(S,'№','№');
S := REPLACE(S,'є','є');
S := REPLACE(S,'ј','ј');
S := REPLACE(S,'Ѕ','Ѕ');
S := REPLACE(S,'ѕ','ѕ');
S := REPLACE(S,'ї','ї');
S := REPLACE(S,'А','А');
S := REPLACE(S,'Б','Б');
S := REPLACE(S,'В','В');
S := REPLACE(S,'Г','Г');
S := REPLACE(S,'Д','Д');
S := REPLACE(S,'Е','Е');
S := REPLACE(S,'Ж','Ж');
S := REPLACE(S,'З','З');
S := REPLACE(S,'И','И');
S := REPLACE(S,'Й','Й');
S := REPLACE(S,'К','К');
S := REPLACE(S,'Л','Л');
S := REPLACE(S,'М','М');
S := REPLACE(S,'Н','Н');
S := REPLACE(S,'О','О');
S := REPLACE(S,'П','П');
S := REPLACE(S,'Р','Р');
S := REPLACE(S,'С','С');
S := REPLACE(S,'Т','Т');
S := REPLACE(S,'У','У');
S := REPLACE(S,'Ф','Ф');
S := REPLACE(S,'Х','Х');
S := REPLACE(S,'Ц','Ц');
S := REPLACE(S,'Ч','Ч');
S := REPLACE(S,'Ш','Ш');
S := REPLACE(S,'Щ','Щ');
S := REPLACE(S,'Ъ','Ъ');
S := REPLACE(S,'Ы','Ы');
S := REPLACE(S,'Ь','Ь');
S := REPLACE(S,'Э','Э');
S := REPLACE(S,'Ю','Ю');
S := REPLACE(S,'Я','Я');
S := REPLACE(S,'а','а');
S := REPLACE(S,'б','б');
S := REPLACE(S,'в','в');
S := REPLACE(S,'г','г');
S := REPLACE(S,'д','д');
S := REPLACE(S,'е','е');
S := REPLACE(S,'ж','ж');
S := REPLACE(S,'з','з');
S := REPLACE(S,'и','и');
S := REPLACE(S,'й','й');
S := REPLACE(S,'к','к');
S := REPLACE(S,'л','л');
S := REPLACE(S,'м','м');
S := REPLACE(S,'н','н');
S := REPLACE(S,'о','о');
S := REPLACE(S,'п','п');
S := REPLACE(S,'р','р');
S := REPLACE(S,'с','с');
S := REPLACE(S,'т','т');
S := REPLACE(S,'у','у');
S := REPLACE(S,'ф','ф');
S := REPLACE(S,'х','х');
S := REPLACE(S,'ц','ц');
S := REPLACE(S,'ч','ч');
S := REPLACE(S,'ш','ш');
S := REPLACE(S,'щ','щ');
S := REPLACE(S,'ъ','ъ');
S := REPLACE(S,'ы','ы');
S := REPLACE(S,'ь','ь');
S := REPLACE(S,'э','э');
S := REPLACE(S,'ю','ю');
S := REPLACE(S,'я','я');

答案 1 :(得分:0)

你在寻找转换吗?

select CONVERT('шт', 'AL32UTF8', 'CL8MSWIN1251') from dual

我没有运行它,因为我通过DB使用UTF,但你可能需要使用编码。

这是一个链接:http://docs.oracle.com/cd/B28359_01/server.111/b28286/functions027.htm