本文介绍了解码quoted-printables的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种解码quoted-printables的方法。

I am looking for a way to decode quoted-printables.

quoted-printables适用于阿拉伯字符,如下所示:

The quoted-printables are for arabic characters and look like this:

我需要将它转换为字符串,并将其存储或显示..

I need to convert it to a string, and store it or display..

我已经在stackoverflow上看到了相反的方式(编码) ,但找不到解码。

I've seen post on stackoverflow for the other way around (encoding), but couldn't find decoding.

推荐答案

嗯,这有点hacky但是你可以替换 = 带有字符的字符,并使用NSString的 stringByReplacingPercentEscapesUsingEncoding:方法。否则,您基本上可以在=字符上拆分字符串,将每个元素转换为字节值(使用NSScanner轻松完成),将字节值放入C数组中,并使用NSString的 initWithBytes:length:encoding :方法。

Uhm, it's a little hacky but you could replace the = characters with a % character and use NSString's stringByReplacingPercentEscapesUsingEncoding: method. Otherwise, you could essentially split the string on the = characters, convert each element to a byte value (easily done using NSScanner), put the byte values into a C array, and use NSString's initWithBytes:length:encoding: method.

请注意,您的示例在技术上不是引用可打印格式,它指定quoted-printable是三个字符序列由 = 字符后跟两个十六进制数字组成。

Note that your example isn't technically in quoted-printable format, which specifies that a quoted-printable is a three character sequence consisting of an = character followed by two hex digits.

这篇关于解码quoted-printables的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 02:02