什么是英寸宽字符串"在C语言? [英] What is a "wide character string" in C language?

查看:184
本文介绍了什么是英寸宽字符串"在C语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我碰到这本书就来了:

wscanf(L"%lf", &variable);

,其中第一个参数是为wchar_t * 的类型

这个S不同于 scanf函数(%LF,&安培;可变); ,其中第一个参数是类型的的char *

This s different from scanf("%lf", &variable); where the first parameter is of type char *.

那么,还有什么能比的差异。我从来没有听说过宽字符串之前。我听说过一些所谓的原始字符串字面量正在打印的字符串,因为它是(不需要的东西像转义序列),但是,这是不是在C

So what is the difference than. I have never heard "wide character string" before. I have heard something called Raw String Literals which is printing the string as it is (no need for things like escape sequences) but that was not in C.

推荐答案

确切的宽字符本质是(故意)左实现定义的。

The exact nature of wide characters is (purposefully) left implementation defined.

当他们第一次发明了 wchar_t的的概念,ISO 10646和统一code仍在互相竞争(而他们现在,主要是配合)。而不是试图法令,具有国际性质是一个或另一个(或可能别的东西完全),他们只是提供了一个类型(以及某些功能)的实现可以定义为他们选择支持国际字符集。

When they first invented the concept of wchar_t, ISO 10646 and Unicode were still competing with each other (whereas they now, mostly cooperate). Rather than try to decree that an international character would be one or the other (or possibly something else entirely) they simply provided a type (and some functions) that the implementation could define to support international character sets as they chose.

不同的实现有无的行使对变化的潜力。例如,如果你使用微软的编译器在Windows上, wchar_t的将是一个16位的控股UTF-16统一code(原举行了UCS-2统一code,但是这是现在正式过时)。

Different implementations have exercised that potential for variation. For example, if you use Microsoft's compiler on Windows, wchar_t will be a 16-bit type holding UTF-16 Unicode (originally it held UCS-2 Unicode, but that's now officially obsolete).

在Linux中, wchar_t的就会更经常是32位的,持UCS-4 / UTF-32连接codeD的Uni code。 GCC的端口至少有一些其他的操作系统做同样的,虽然我从来没有试图确认它总是如此。

On Linux, wchar_t will more often be a 32-bit type, holding UCS-4/UTF-32 encoded Unicode. Ports of gcc to at least some other operating systems do the same, though I've never tried to confirm that it's always the case.

然而,有,没有这样的保证。至少在理论上在Linux上的实现可以使用16位或一个在Windows上可以使用32位或任何一个可以决定使用64位(虽然我有点惊讶地看到,在现实中)。

There is, however, no guarantee of that. At least in theory an implementation on Linux could use 16 bits, or one on Windows could use 32 bits, or either one could decide to use 64 bits (though I'd be a little surprised to see that in reality).

在任何情况下,事情是如何的意的总体思路的工作,是一个 wchar_t的足以重新present一个code点。对于I / O,该数据是为了从外部重新presentation(不管它是什么)转换成 wchar_t的 s,这(被认为)让他们比较容易操纵。然后输出过程中,他们再次得到转化成您所选择的编码(可能是从你读的编码完全不同)。

In any case, the general idea of how things are intended to work, is that a single wchar_t is sufficient to represent a code point. For I/O, the data is intended to be converted from the external representation (whatever it is) into wchar_ts, which (is supposed to) make them relatively easy to manipulate. Then during output, they again get transformed into the encoding of your choice (which may be entirely different from the encoding you read).

这篇关于什么是英寸宽字符串"在C语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆