When LOCALETYPE(*LCOALEUTFp) is specified, wide-character literals are always represented in UTF-32 format, regardless of the CCSID used by the root source file. In addition, #pragma convert() will have no effect on the wide-character literals.
When LOCALETYPE(*LOCALEUCS2) is specified, wide-character literals will always represent a UCS-2 character literal regardless of CCSID used by the root source file. In addition, #pragma convert() will ignore wide-character literals when converting characters from one codepage to another.
Example:
This example assumes a CCSID 37 source:
#include <stdio.h> #include <wchar.h> void main () { #pragma convert (500) wchar_t wcs1[] = L"[]"; char str1[] = "[]"; #pragma convert (0) wchar_t wcs2[] = L"[]"; char str2[] = "[]"; printf("str1 = %x %x\n", str1[0], str1[1]); printf("str2 = %x %x\n", str2[0], str2[1]); printf("wcs1 = %04x %04x\n", wcs1[0], wcs1[1]); printf("wcs2 = %04x %04x\n", wcs2[0], wcs2[1]); }
Running the program would result in output similar to that shown below.
str1 = 4a 5a str2 = ba bb wcs1 = 005b 005d wcs2 = 005b 005d
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.