现代 C++ 中的基本字符串与 Unicode 字符串使用指南

本文将探讨在现代 C++ 中如何处理基本字符串和 Unicode 字符串。我们将对比传统的 std::string 与新引入的 std::u16string 和 std::u32string,并通过实例展示其用法。

一、基本字符串:std::string

在 C++ 中,最常用的字符串类型是 std::string。这是一个非常灵活且高效的类,用于处理基本的 ASCII 字符串。

#include   
#include   

int main() {  
    std::string str = "Hello, World!";  
    std::cout