【问题标题】:C++ Reading UTF8 buffer using wide streamC++ 使用宽流读取 UTF8 缓冲区
【发布时间】:2023-03-22 09:35:01
【问题描述】:

我的问题是我有一个 utf8 格式的缓冲区存储在 std::string 中。我想把它作为一根细流来提供,以提振精神。在不将整个 std::string 转换为 std::wstring 的情况下如何做到这一点。我想要一个流,它可以作为从 utf8 到系统上任何 wchar_t 的只读视图。

【问题讨论】:

    标签: c++ utf-8 inputstream utf-16


    【解决方案1】:

    您可以使用u8_to_u32_iteratorwchar_t 不足以容纳所有字符。您也可以传递int32 迭代器来增强精神功能,或者只是编写一个包装器,它将int32 迭代器转换为wchar_t 迭代器。或为此目的使用u32_to_u16_iteratorhttp://www.boost.org/doc/libs/1_53_0/libs/regex/doc/html/boost_regex/ref/internal_details/uni_iter.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-03-15
      • 1970-01-01
      • 2011-11-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多