Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当人们或软件说某物是 GB2312 编码时,他们通常表示它是用 GBK 编码编码的,也就是 Microsoft 的 CP936。GB2312 是 1980 年代使用的 GBK 的子集,但两者都是同一编码系列的一部分。
顺便说一句,即将发布的 WhatWG编码规范建议将标记为“gb2312”的任何文本视为 GBK 编码文本。
因此,尝试u'囧'.encode('gbk')or u'囧'.encode('cp936')or u'囧'.encode('windows-936')。
u'囧'.encode('gbk')
u'囧'.encode('cp936')
u'囧'.encode('windows-936')
囧不在gb2312,用gb18030代替。我猜当她面对未知字符时,Firefox 可能会扩展编码方法。