Q编码和Quoted Printable的区别?
Difference with Q encoding and Quoted Printable?
如果我问的是初学者问题,我深表歉意。
请问RFC2047 4.2 The "Q" encoding and RFC 2045 6.7 Quoted-Printable Content-Transfer-Encoding有什么区别?
来自 RFC2047:
The "Q" encoding is similar to the "Quoted-Printable" content-transfer-encoding defined in RFC 2045.
我正在尝试使用 Ruby 实现解码逻辑。我已阅读下面的答案,并试图理解为什么 Q 编码 .
需要 first.gsub('_',' ')
Is there a way to decode q-encoded strings in Ruby?
通过再次阅读 RFC2047,我意识到在下划线被编码为 =5F
.
的情况下,下面的方法无法正确解码下划线
decoded = m[3].unpack('M').first.gsub('_',' ')
而是如RFC2047 4.2 (2)最后一句所述:
Note that the "_" always represents hexadecimal 20, even if the SPACE character occupies a different code position in the character set in use.
我先将文字下划线替换回 =20
,然后解压。
我编码如下:
decoded = m[3].gsub('_', '=20').unpack('M').first()
如果我问的是初学者问题,我深表歉意。
请问RFC2047 4.2 The "Q" encoding and RFC 2045 6.7 Quoted-Printable Content-Transfer-Encoding有什么区别?
来自 RFC2047:
The "Q" encoding is similar to the "Quoted-Printable" content-transfer-encoding defined in RFC 2045.
我正在尝试使用 Ruby 实现解码逻辑。我已阅读下面的答案,并试图理解为什么 Q 编码 .
需要first.gsub('_',' ')
Is there a way to decode q-encoded strings in Ruby?
通过再次阅读 RFC2047,我意识到在下划线被编码为 =5F
.
decoded = m[3].unpack('M').first.gsub('_',' ')
而是如RFC2047 4.2 (2)最后一句所述:
Note that the "_" always represents hexadecimal 20, even if the SPACE character occupies a different code position in the character set in use.
我先将文字下划线替换回 =20
,然后解压。
我编码如下:
decoded = m[3].gsub('_', '=20').unpack('M').first()