Oracle Solaris Studio 12.2:C++ 用户指南

A.2.186.1 值

如果需要支持使用 ISO10646 UTF-16 文本字符串的国际化应用程序,可指定 -xustr=ascii_utf16_ushort。可以通过指定 -xustr=no 来禁用编译器对 U"ASCII_string" 字符串或字符文字的识别。该选项在命令行上最右侧的实例覆盖了先前的所有实例。

可以指定 -xustr=ascii_ustf16_ushort,而无需同时指定 U"ASCII_string" 文本字符串。这样执行时不会出现错误。

缺省值

缺省值为 -xustr=no。如果指定了没有参数的 -xustr,编译器将不接受该选项,而是发出一个警告。如果 C 或 C++ 标准定义了语法的含义,那么缺省设置是可以更改的。

示例

以下示例显示了前面带有 U 的带引号文本字符串。另外,还显示了指定 -xustr 的命令行。


example% cat file.cc
const unsigned short *foo = U"foo";
const unsigned short bar[] = U"bar";
const unsigned short *fun() {return foo;}
example% CC -xustr=ascii_utf16_ushort file.cc -c

8 位字符文字可以带有 U 前缀,以形成一个 unsigned short 类型的 16 位 UTF-16 字符。示例:


const unsigned short x = U'x';    
const unsigned short y = U'\x79';