问题描述
我正在尝试在Oracle
数据库中复制一些python 2.7
代码.
I am trying to replicate some python 2.7
code in Oracle
database.
当尝试复制base64 decoding
时,我得到了不同的输出.
When trying to replicate base64 decoding
, I am getting different output.
Python代码:
# -*- coding: utf-8 -*-
import base64
print(base64.b64decode('rO0ABXVyAAJbQqzzF/gGCFTgAgAAeHAAAAAgGLCRnyhEZhzJJRd7EoVPp2XWTRgDNYHq4cAghvXvTaw='))
Python代码输出:
�� ur [B���T� xp ���(Df�%{�O�e�M5���� ���M�
Oracle查询:
select utl_raw.cast_to_varchar2(UTL_ENCODE.BASE64_DECODE( UTL_RAW.CAST_TO_RAW ('rO0ABXVyAAJbQqzzF/gGCFTgAgAAeHAAAAAgGLCRnyhEZhzJJRd7EoVPp2XWTRgDNYHq4cAghvXvTaw='))) from dual;
select utl_raw.cast_to_varchar2(UTL_ENCODE.BASE64_DECODE( UTL_RAW.CAST_TO_RAW ('rO0ABXVyAAJbQqzzF/gGCFTgAgAAeHAAAAAgGLCRnyhEZhzJJRd7EoVPp2XWTRgDNYHq4cAghvXvTaw='))) from dual;
Oracle查询输出:
�ur[B��T�xp �Df�{��M5����
输出似乎部分相同,但不完全相同.
The output seems to be partially same but not completely.
可能是由于缺乏知识,我缺少基本知识.请提出建议.
May be due to lack of knowledge, I am missing basics. Please suggest.
推荐答案
我已经使用UTL_ENCODE.TEXT_DECODE
方法和AL32UTF8
实现了与encode_charset相同的功能.
I have achieved the same using UTL_ENCODE.TEXT_DECODE
method and AL32UTF8
as encode_charset .
declare
v2 varchar2(4000 char);
begin
v2 := UTL_ENCODE.TEXT_DECODE(
'rO0ABXVyAAJbQqzzF/gGCFTgAgAAeHAAAAAgGLCRnyhEZhzJJRd7EoVPp2XWTRgDNYHq4cAghvXvTaw=',
'AL32UTF8',
UTL_ENCODE.BASE64);
DBMS_OUTPUT.PUT_LINE('v2='||v2);
end;
输出:
v2=��ur[B���T�xp ���(Df�%{�O�e�M5���� ���M�
这篇关于Python和Oracle中的Base 64解码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!