# string
## 字符串字面量
~~~
const char* a = "string a";
const char* b = u8"string b"; // UTF-8
const char16_t* c = u"string c"; // UTF-16
const char32_t* d = U"string d"; // UTF-32
const char* e = R"(string e1 "\\
stirng e2)"; // raw string
std::cout << a << std::endl;
std::cout << b << std::endl;
std::cout << c << std::endl;
std::cout << d << std::endl;
std::cout << e << std::endl;
R原始字符
auto xml = R"(
)";
~~~
## string常用方法
```
string str1 = "Hello World"
string str2 = "Hello World"s
string str2 = "hellow"sv string_veiw类型
```
```
```
## 高级数值转换
```
定义于头文件
std::string to_string( int value );
std::string to_string( long value );
std::string to_string( long long value );
std::string to_string( unsigned value );
std::string to_string( unsigned long value );
std::string to_string( unsigned long long value );
std::string to_string( float value );
std::string to_string( double value );
std::string to_string( long double value );
stoi
stol
stoll
转换字符串为有符号整数
(函数)
stoul
stoull
转换字符串为无符号整数
(函数)
stof
stod
stold
转换字符串为浮点值
```