Garbled full (four)

zhaozj2021-02-08  238

Quoted-Printable

Quoted-Printable is referred to as qp, which is generally used in the Email system. It is usually used for the 8-bit character of a small amount of text, such as foxmail, uses it to do coding for the subject and the alias. This coding should be well identified: it has a lot of "=". Here is an example of it:

MIME-VERSION: 1.0

Content-Transfer-Encoding: Quoted-Printable

= A1 = b6 = C2 = D2 = C2 = EB = CB = E3 = b7 = a8 = b4 = f3 = c8 = AB = a1 = b7

= D7 = f7 = D5 = DF: MOGAO = A3 = AC = B0 = D7 = D4 = C6 = bb = c6 = ba = D7 = D5 = be = a3 = a8TELNET: //202.112.20.132: 23 = A3 = A9 = B3 = C9 = D4 = b1 = a1 = a3

= C4 = aa = b8 = DF = C8 = ED = BC = Fe = b9 = a4 = D7 = f7 = ca = d2 = a3 = bahttp: //mogao.bentiun.net

Emailto: Mogao@371.net

***************************************************

* = B3 = fd = C1 = CB = BC = C7 = D2 = E4 = Ca = B2 = C3 = B4 = B6 = BC = B2 = bb = b4 = f8 = D7 = DF = A3 = AC = B3 = fd = C1 = CB = D7 = E3 = BC = a3 = ca = b2 = c3 = b4 = b6 = bc = b2 = bb = c1 = f4 = cf = c2 *

***************************************************

You can separate it into a file, named: mogao.eml, double-click to open it with Outlook (the original information of the first two behaviors, starting from the fourth line as coding content).

QP's algorithm can be said to be the easiest to say that the coded efficiency is the lowest (its coding rate is 1: 3), which is specifically to handle 8-bit characters. Its algorithm is: read a character, if the ASCII code is greater than 127, that is, the character's top 8 is 1, the encoding is performed, otherwise it is ignored (sometimes 7-bit character encoding). The encoding is simple, look at the C language description below:

/ * QP code * /

Void QP (Unsigned Char Sour, Unsigned Char first, unsigned char second)

/ *

SOUR: Character to be encoded

First: The first character after encoding

Second: The second character encoded

First and second are return values

* /

{

IF (Sour> 127)

{first = SOUR >> 4;

SECOND = SOUR & 15;

IF (first> 9) first = 55;

Else First = 48;

IF (Second> 9) Second = 55; Else Second = 48;

Printf ("% C% C% C", '=', first, second);

}

}

/ * QP decoding * /

Void UQP (Unsigned Char Sour, Unsigned Char SECOND)

/ *

Sour: Decoded characters

First: QP code first character

Second: The second character of QP code

SOUR is the return value

* /

{

IF (first> = 65) first- = 55;

Else first- = 48;

IF (Second> = 65) second- = 55;

Else Second- = 48;

Sour = NULL;

SOUR = first << 4;

Sour | = second;

}

See RFC2045 for detailed descriptions and accurate definitions of QP.

转载请注明原文地址:https://www.9cbs.com/read-1213.html

New Post(0)