本文介绍了在C ++中将UTF-8转换为ANSI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在任何地方都找不到这个问题的答案.

I can't find an answer to this question anywhere.

如何在C ++中将字符串从UTF-8转换为ANSI(扩展的ASCII)?

How can I convert a string from UTF-8 to ANSI (extended ASCII) in C++?

推荐答案

通常,人们使用libiconv(网页),它是可移植的,并且可以在大多数平台上运行.正如KerrekSB所提到的,如果您将字符集视为扩展的ASCII",您将陷入麻烦–我确信至少有一百个字符集可以称为扩展的ASCII",包括UTF-8.

Generally, one uses libiconv (webpage), which is portable and runs on most platforms. As KerrekSB mentioned, you will get in deep trouble if you think of a character set as "extended ASCII" -- I'm sure there are at least a hundred character sets that could be called "extended ASCII", including UTF-8.

此外,请确保您知道所需的编码:ISO-8859-1或CP1252. Windows版本用其他打印字符替换了C1控制代码.

Also, make sure you know which encoding you want: ISO-8859-1 or CP1252. The Windows version replaces the C1 control codes with additional printing characters.

这篇关于在C ++中将UTF-8转换为ANSI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 16:58