问题描述
我想知道 Stack Overflow 社区在使用 unicode 或多字节字符集创建项目(这里主要考虑 C++)时是怎么想的.
I'm wondering what the Stack Overflow community thinks when it comes to creating a project (thinking primarily c++ here) with a unicode or a multi-byte character set.
使用 Unicode 有什么好处从一开始就意味着所有你的字符串将是宽格式?是否有性能问题/更大内存要求,因为标准使用更大的字符?
Are there pros to going Unicodestraight from the start, implying allyour strings will be in wide format?Are there performance issues / largermemory requirements because of astandard use of a larger character?
这种方法有优势吗?做一些处理器架构更好地处理宽字符?
Is there an advantage to this method?Do some processor architectureshandle wide characters better?
有什么理由让你的如果您不打算进行 Unicode 项目支持其他语言吗?
Are there any reasons to make yourproject Unicode if you don't plan onsupporting additional languages?
使用多字节字符集创建项目的原因是什么?
What reasons would one have for creating a project with a multi-byte character set?
上述所有因素如何在高性能环境(例如现代视频游戏)中发生冲突?
How do all of the factors above collide in a high performance environment (such as a modern video game) ?
推荐答案
我要评论的两个问题.
首先,您没有提及您的目标平台是什么.尽管最近的 Windows 版本(Win2000、WinXP、Vista 和 Win7)支持使用字符串的多字节和 Unicode 版本的系统调用,但 Unicode 版本更快(多字节版本是转换为 Unicode 的包装器,调用 Unicode 版本,然后转换任何返回的字符串回到多字节).因此,如果您进行大量此类调用,Unicode 会更快.
First, you don't mention what platform you're targeting. Although recent Windows versions (Win2000, WinXP, Vista and Win7) support both Multibyte and Unicode versions of system calls using strings, the Unicode versions are faster (the multibyte versions are wrappers that convert to Unicode, call the Unicode version, then convert any returned strings back to mutlibyte). So if you're making a lot of these types of calls the Unicode will be faster.
仅仅因为您不打算明确支持其他语言,如果您的应用程序保存并显示用户输入的文本,您仍然应该考虑支持 Unicode.仅仅因为您的应用程序是单语的,并不意味着它的所有用户也都是单语的.他们可能非常乐意使用您的英语 GUI,但可能希望以他们自己的语言输入姓名、评论或其他文本并使其正确显示.
Just because you're not planning on explicitly supporting additional languages, you should still consider supporting Unicode if your application saves and displays text entered by the users. Just because your application is unilingual, it doesn't follow that all it's users will be unilingual too. They may be perfectly happy to use your English language GUI, but might want to enter names, comments or other text in their own language and have them displayed properly.
这篇关于C++ 项目类型:unicode vs 多字节;利弊的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!