C++相当于 PHP 在 Linux 中的utf8_decode函数
C++ equivalent of PHP's utf8_decode function in Linux
可能的重复:
C &Boost:Encode/decode UTF-8
我需要将带有UTF-8编码文本的wstring
转换为(错误地)中的新校正WSTRING。
PHP的ut8_decode
功能可以完美处理。我也可以通过ICONV进行操作:
来自:
# cat wtf | grep 1856 | awk '{print $2}'
å°ç³å·ãçç¾
to:
#cat wtf | grep 1856 | awk '{print $2}'| iconv -f utf8 -t ISO-8859-1
小石川 玉美
在C#中,我能够以:
获得这种行为public static string Utf8Decode(string utf8me) {
return Encoding.UTF8.GetString(Encoding.GetEncoding(28591).GetBytes(utf8me));
}
我的大部分搜索都提出了特定于Windows的解决方法。由于我在Linux上,我认为我将要使用ICONV,但我不确定如何在C 中执行此操作。
iconv
也是函数 iconv()
请参阅GLIBC文档:
- http://www.gnu.org/software/libc/manual/html_node/generic-charset-conversion.html
- http://www.gnu.org/software/libc/manual/html_node/iconv-examples.html
相关文章:
- C ++如何使用UTF8十六进制代码打印UTF8符号?
- C++MySQL连接器没有utf8
- 从/到 UTF-8/UTF-16 的转换需要(例如:utf8 -> 代码点,然后代码点到 utf16)或(例如:utf8 -> utf16)?
- C++和带有国家符号的文件路径(也许用 UTF8 编码)
- 'std::wstring_convert'尽可能多地转换(从 UTF8 文件读取块)
- 将utf16宽std::wstring转换为utf8窄std::string以获得罕见字符时出现问题
- python UnicodeDecodeError: 'utf8' codec 无法解码字节
- MSVC UTF8字符串编码使用了不正确的代码点
- 使用C++将越南语字符从ISO88591、UTF8、UTF16BE、UTF16LE和UTF16编码为十六进制,反之亦然
- 如何使 std::正则表达式匹配 Utf8
- 有没有非utf8字符这样的东西
- VS2019编译器将没有BOM文件的UTF8错误解释为ANSI
- Arduino在通过Serial读取utf8时表现奇怪
- 如何在utf8中获得代码点文字
- 在 C++ 中将 utf8 wstring 转换为窗口中的字符串
- 检查是否需要 utf8 转换并转换为 utf8
- 如何使用C++在Windows中输出和输入UTF8或UTF16 Unicode文本?
- C++ 检查 UTF8 字符串包含指定的字符
- 使用 iconv 进行 UTF8 转换的输出不正确
- tiny-utf8:以字符/代码点为单位获取偏移量