[英]python base64 string decoding
I've got what's supposed to be a UCS-2 encoded xml document that I've managed to build a DOM based on minidom after some tweaking. 我已经得到了一个UCS-2编码的xml文档,我已经设法在经过一些调整后基于minidom构建了一个DOM。
The issue is that I'm supposed to have some data encoded on base64. 问题是我应该在base64上编码一些数据。 I know for a fact that: 我知道一个事实:
AME= (or \x00A\x00M\x00E\x00=) is base64 code for Á
How would I decode that? 我该如何解码呢?
http://www.fileformat.info/info/unicode/char/00c1/index.htm shows that the unicode representation for Á is: u"\Á" and in UTF-16: 0x00C1 http://www.fileformat.info/info/unicode/char/00c1/index.htm显示Á的unicode表示形式为:u“\\ u00C1”和UTF-16:0x00C1
base64.b64decode('AME=').decode('UTF-16')
shows 节目
u'\uc100'
as the unicode representation for the character, but it looks byte-swapped. 作为字符的unicode表示,但它看起来是字节交换的。
Any idea on how to decode it? 有关如何解码的任何想法?
Check this out 看一下这个
>>> import base64
>>> base64.b64decode('AME=').decode('UTF-16')
u'\uc100'
>>> base64.b64decode('AME=').decode('UTF-16LE')
u'\uc100'
>>> base64.b64decode('AME=').decode('UTF-16BE')
u'\xc1'
Perhaps you are looking for big endian decoding? 也许您正在寻找大端解码?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.