DougEwell2@cs.com wrote:
> In a message dated 2001-10-31 10:07:44 Pacific Standard Time,
> drepper@redhat.com writes:
>> This is wrong. wchar_t strings can of course be printed. Reading the
>> ISO C standard would tell you to use
>>
>> printf ("%ls", wstr);
>>
>> can be used to print wchar_t strings which are converted to a byte
>> stream according to the currently selected locale. Eventually it has
> But won't this approach fail as soon as we hit a 0x00 byte (i.e. the
> high 8 bits of any Latin-1 character)?
I'm not sure what you're alluding to here. As long as
all characters in wstr belong to the repertoire of the encoding/
character set of the current locale (that is, unless one
passes wstr containing Chinese characters to printf() in,
say, de_DE.ISO8859-1 locale),
there should not be any problem with using '%ls' to
print out wstr with printf(). Of course, 'printf ("%ls", wstr) '
doesn't achieve what the original question asked for, but that
question has already been answered, hasn't it?
fprintf() man page in Single Unix Spec v2 (perhaps,
I should look at the actual C standard) doesn't seem to say anything
about what to expect
when wstr contains characters outside the repertoire of
the character set of the current locale. wcrtomb() is called
for each wide char in wstr when '%ls' is used
to print out wstr. According wcrtomb() man page,
errno is set to EILSEQ if an invalid wide char.
is given to it, but it's not clear whether
'invalid wide char' in the man page of wcrtomb() includes
valid wide chars which are NOT convertible to the encoding
of the current locale.
Jungshik Shin
This archive was generated by hypermail 2.1.2 : Thu Nov 01 2001 - 16:12:22 EST