Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to convert bytes into characters
How to convert bytes into characters
This is the part of the computer that stores information. Char is a character type, and byte is a byte type (0-255). When participating in arithmetic operation, Char type will be automatically converted into an integer. For example, the character A will be converted into the corresponding ASCII code. Char is used to represent a character, not a word, because a word takes up two bytes.

Only one byte is needed to store an ANSI character. Note that the emphasis here is on ANSI characters, not Unicode characters. Because Unicode takes up two bytes. Byte type is the freest type.

It takes up a byte, but it doesn't define the purpose of this byte. Char is defined as unsigned byte type. That is, an unsigned byte. It takes up all 8 bits of a byte.

The data range represented is between 0 and 255. You are sure that the string you are processing is a standard ANSI string, so you can directly process it byte by byte without conversion. The string to be processed is an indefinite or unified Unicode string, and then it is converted and processed.

Extended data:

Byte is a unit of measurement used by computer information technology to measure storage capacity. As a unit, a binary number string is a very small unit of information. The most commonly used bytes are octets, that is, binary numbers containing eight bits.

ASCII code: An English letter (regardless of case) occupies one byte. As a digital unit in a computer, a sequence of binary numbers is usually an 8-bit binary number. Convert to decimal, the minimum value is-128 and the maximum value is 127. For example, ASCII code is one byte.

UTF 8 encoding: one English character equals one byte, and one Chinese (including traditional Chinese) equals three bytes. Chinese punctuation takes up three bytes and English punctuation takes up one byte.

Unicode encoding: one English is equal to two bytes, and one Chinese (including traditional Chinese) is equal to two bytes. Chinese punctuation accounts for two bytes, and English punctuation accounts for two bytes.

An array of any data type needs 20 bytes of memory space, and each array dimension needs 4 bytes, plus the space occupied by the data itself. The memory space occupied by data can be calculated by multiplying the number of data elements by the size of each element.

For example, data in a one-dimensional array consisting of four 2-byte integer data elements accounts for 8 bytes. These 8 bytes plus another 24 bytes make the total memory space required for the array 32 bytes.

Baidu encyclopedia-bytes