Topic
  • No replies
SystemAdmin
SystemAdmin
196 Posts

Pinned topic Is there a way to make runtime library routines treat wchar_t data as UCS-2

‏2010-12-06T17:17:55Z |
Is there a way to make runtime library routines such as wcstod and printf treat wchar_t data as UCS-2?

The -W c,'convlit(,UNICODE)' compiler option causes wide literal strings to use the UCS-2 encoding, but seems to have no effect on runtime library routines.

BTW I'm compiling with c89 in the z/OS shell. I can not switch my program to using ASCII. It must be an EBCDIC program.

Thank you.

David Liebtag
Updated on 2011-01-12T15:15:53Z at 2011-01-12T15:15:53Z by dinoxlc
  • SystemAdmin
    SystemAdmin
    196 Posts

    Re: Is there a way to make runtime library routines treat wchar_t data as UCS-2

    ‏2011-01-11T23:47:57Z  
    If I have an array of wide characters containing UCS2 data, is there a way to get printf to respect it is UCS2 and print it correctly?

    Thank you.

    David Liebtag
  • dinoxlc
    dinoxlc
    1 Post

    Re: Is there a way to make runtime library routines treat wchar_t data as UCS-2

    ‏2011-01-12T15:15:53Z  
    If I have an array of wide characters containing UCS2 data, is there a way to get printf to respect it is UCS2 and print it correctly?

    Thank you.

    David Liebtag
    Run time library functions that deal with wide character data require a proper locale that supports the encoding of wide characters. If the active locale does not support UCS2 encoding there is no way for such run time library functions, including printf, to properly process UCS2 data.

    Typically the active locale matches the environment in which an application is running. If a display or a printer is based on EBCDIC encoding, the application that uses a UCS2 based locale will not work unless automatic conversion is active and the output is directed to a file (e.g. stdout) which is tagged. Even then, the information produced by the application must contain characters that are supported by EBCDIC devices or it will not be shown properly.

    If it is known that the wide character data is UCS2 based, the application can convert it using iconv run time library function before it tries to display it to an EBCDIC device (assuming that the characters contained in the UCS2 based data are supported by EBCDIC devices).