Why is string called basic stringchar in C++

//Assuming the following is the definition of the basic_string class (it doesn't matter whether its definition is complete), 
//then there is a question? 
// Are there different types of strings? Need to use template 
template < class  T >
 class  basic_string 
{ 
private :
    T* _str;
    //...
};

Here’s what you need to know about encoding:

The origin of coding :
Computers can only calculate and recognize [binary] , and computers must recognize words in order to interact with computers and communicate with each other through computers.
As a result, the birth of ASCII encoding, which started in the late 1950s and was finalized in 1967, is the original American national standard for different computers to use as a common Western character encoding standard when communicating with each other.

For example:
the maximum range of decimal numbers that can be represented by 8-bit binary is, 0000 0000 ~ 1111 1111 = 0 ~ 255, a total of 256 different numbers.

ASCII encoding is a correspondence table formed by corresponding commonly used English characters and symbols with 256 numbers one by one.

Since the computer was invented by the Americans, only 127 letters were encoded into the computer at the earliest, that is, uppercase and lowercase English letters, numbers and some symbols. This encoding table is called ASCII encoding;

Later, it was expanded by 128, which is called extended ASCII code.

In this way, when we enter characters, the computer converts them into decimal, and then converts them into binary, which can be calculated or transmitted by the computer.

Because computers were invented in the United States at that time, the ASCII code table was invented only for those of them who were learning English. But if computers want to become popular, they must have a set of encoding tables that provide a set of characters all over the world, so Unicode was born.

Unicode (Universal Coded Character Set) appeared, which organizes and encodes most of the world’s writing systems, so that computers can present and process characters in a simpler way. Its purpose is to provide a uniform for all characters. Code, any platform, system, device, application or language can be used without risk.
Unicode in turn contains utf-8, utf-16, utf-32.

For our country, it is obvious that we have too many characters. 8 bits can obviously represent 256 Chinese characters, which is definitely not enough. Then we can use 16 bits, that is, two bytes to represent Chinese characters.
The texts of different countries are represented by [strings] , so basic_string is used. to represent multiple types.

Leave a Comment

Your email address will not be published. Required fields are marked *