本文介绍了为什么不为wchar_t广泛应用于code为Linux /相关的平台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这令我着迷,所以我要问 - 是什么原因是 wchar_t的不使用如此广泛的类Linux的Linux /系统,因为它是在Windows?具体来说,Windows API的使用 wchar_t的内部,而我认为Linux没有,这反映了一些使用开放源码包的字符类型。

This intrigues me, so I'm going to ask - for what reason is wchar_t not used so widely on Linux/Linux-like systems as it is on Windows? Specifically, the Windows API uses wchar_t internally whereas I believe Linux does not and this is reflected in a number of open source packages using char types.

我的理解是,鉴于这需要多个字节重新present,然后在的char [] C code>表格 C 拆分为的char *几个地区,而它构成一个单元 wchar_t的[] 。那岂不是更容易的话,使用 wchar_t的始终?难道我错过了否定这种差异由于技术原因?或者只是一个收养问题?

My understanding is that given a character c which requires multiple bytes to represent it, then in a char[] form c is split over several parts of char* whereas it forms a single unit in wchar_t[]. Is it not easier, then, to use wchar_t always? Have I missed a technical reason that negates this difference? Or is it just an adoption problem?

推荐答案

wchar_t的是一个宽字符与平台定义的宽度,这并不能真正帮助很多。

wchar_t is a wide character with platform-defined width, which doesn't really help much.

UTF-8字符跨越每个字符1-4字节。 UCS-2,其中每个字符正好横跨2个字节,现在已经过时,不能再present完整统一code字符集。

UTF-8 characters span 1-4 bytes per character. UCS-2, which spans exactly 2 bytes per character, is now obsolete and can't represent the full Unicode character set.

这是支持单向code Linux应用程序往往这样做正确的逐字节的存储层之上。 Windows应用程序往往使这种无聊的假设,只有两个字节就行了。

Linux applications that support Unicode tend to do so properly, above the byte-wise storage layer. Windows applications tend to make this silly assumption that only two bytes will do.

略为触及这一点。

wchar_t's Wikipedia article briefly touches on this.

这篇关于为什么不为wchar_t广泛应用于code为Linux /相关的平台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 09:03