1

Introduction

In the work, I encountered the problem of image conversion, encountered a few concepts, checked some information, and recorded it here.

ASCII

The full name of ASCII is American Standard Code for Information Interchange (American Standard Code for Information Interchange), which is a character encoding standard for electronic communications. ASCII codes represent text in computers, telecommunications equipment, and other equipment. Most modern character encodings are based on ASCII, although they support many other characters.

ASCII was developed from telegram codes. The first commercial use was the 7-digit teletype code promoted by Bell Data Services. Work on the ASCII standard began in 1960.10.06, and the American Standards Association (ASA) (now the American National Standards Institute or ANSI for short) X3.2 Subcommittee held its first meeting. In 1963, the first version of the standard was released, with major revisions in 1967, and the most recent update was in 1986. Compared with the earlier telegraph codes, the recommended Bell codes and ASCII codes are for more convenient sorting of the list, and some functions are added for devices other than teletypewriters.

Originally based on the English alphabet, 128 specific characters of ASCII encoding are 7-bit integers, as shown in the following chart, the specific corresponding can be seen here .

30-ascii

95 coded characters are printable, these characters include: 0-9, az, AZ and punctuation marks. In addition, the original ASCII specification included 33 non-printing control codes, which were derived from teletypewriters. Most of them are obsolete, although some are still in common use, such as carriage return, line feed, and tab codes.

For example, the lowercase letter i in ASCII code as 11001001 in binary, 69 in hexadecimal, and 105 in decimal.

Base64

Base64 is a set of encoding schemes similar to the conversion of binary to text, which converts a string representing binary in ASCII into a base 64 representation. The term Base64 is derived from MIME content conversion encoding . Each Base64 number represents exactly 6 bits of data. Three 8-bit bytes can be represented by four 6-bit Base64 numbers.

The specific set of 64 characters chosen to represent the 64-bit value of the base varies from implementation to implementation. The usual strategy is to select 64 most used and printable characters. This combination makes it unlikely that data will be modified when transmitted between information systems. For example, mail is not traditionally a standard 8-bit encoding. For example, the Base64 implementation of MIME uses AZ, az, and 0-9 as the first 62 values. Other variants also share this feature, but the last two values are different in the choice of symbols. One example is UTF -7 .

The earliest realization of this kind of encoding was for the creation of dial-up communication between the same operating systems. Therefore, more assumptions can be made about which characters are safe to use. For example, the uuencode tool uses lowercase characters, numbers, and many punctuation characters, but not lowercase.

The following is a realization of Base64.

Index Char Index Char Index Char Index Char
0 A 16 Q 32 g 48 w
1 B 17 R 33 h 49 x
2 C 18 S 34 i 50 y
3 D 19 T 35 j 51 z
4 E 20 U 36 k 52 0
5 F 21 V 37 l 53 1
6 G 22 W 38 m 54 2
7 H 23 X 39 n 55 3
8 I 24 Y 40 o 56 4
9 J 25 Z 41 p 57 5
10 K 26 a 42 q 58 6
11 L 27 b 43 r 59 7
12 M 28 c 44 s 60 8
13 N 29 d 45 t 61 9
14 O 30 e 46 u 62 +
15 P 31 f 47 v 63 /

Example

Source Text (ASCII) M a n
Octets 77 (0x4d) 97 (0x61) 110 (0x6e)
Bits 0 1 0 0 1 1 0 1 0 1 1 0 0 0 0 1 0 1 1 0 1 1 1 0
Base64
encoded
Sextets 19 22 5 46
Character T W F u
Octets 84 (0x54) 87 (0x57) 70 (0x46) 117 (0x75)

Reference


XXHolic
363 声望1.1k 粉丝

[链接]