Sun Studio 12 Update 1: C++ User's Guide

A.2.186 -xustr={ascii_utf16_ushort|no}

Use this option if your code contains string or character literals that you want the compiler to convert to UTF-16 strings in the object file. Without this option, the compiler neither produces nor recognizes sixteen-bit character string literals. This option enables recognition of the U"ASCII_string" string literals as an array of unsigned short int. Since such strings are not yet part of any standard, this option enables recognition of non-standard C++.

Not all files have to be compiled with this option.

A.2.186.1 Values

Specify -xustr=ascii_utf16_ushort if you need to support an internationalized application that uses ISO10646 UTF-16 string literals. You can turn off compiler recognition of U"ASCII_string" string or character literals by specifying -xustr=no. The right-most instance of this option on the command line overrides all previous instances.

You can specify -xustr=ascii_ustf16_ushort without also specifying a U"ASCII_string" string literal. It is not an error to do so.

Defaults

The default is -xustr=no. If you specify -xustr without an argument, the compiler won’t accept it and instead issues a warning. The default can change if the C or C++ standards define a meaning for the syntax.

Example

The following example shows a string literal in quotes that is prepended by U. It also shows a command line that specifies -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

An 8-bit character literal can be prepended with U to form a 16-bit UTF-16 character of type unsigned short. Examples:


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