-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Bruno Haible <[EMAIL PROTECTED]> writes:
> Roger Leigh wrote:
>> Viewed as hexadecimal (aligned for comparison):
>> "Narrow" UTF-8:
>> Ð Ñ Ð
>> ==> d0 9f d1 82 d0 bd
>
> In UCS-4 these would be
>
> 0000041F 00000442 0000043D
>
>> "Wide" (unknown):
>> B =
>> ==> 1f 42 3d
>
> So you can see that it simply used the low 8 bit of every UCS-4 character.
> Which is broken. Before reporting this as a bug to the GCC people, you
> might want to find out whether it's a bug in std::wcsftime or a bug in
> the std::wcout stream.
I've written a plain [C99] test program, below. This works fine with
wcsftime() and wfprintf(). So, I guess the problem is with "wcout".
If there's a problem like fwide() with iostreams (you can't use
fwprintf and fprintf with the same stream, or change the byte/wide
mode once set), perhaps you can't output to both std::cout and
wtd::wcout? (This appears to be the case; after removing all the
std::cout usage in the previous testcase, std::wcout appears to also
output UTF-8).
Regards,
Roger
#define _GNU_SOURCE
#include <stdio.h>
#include <locale.h>
#include <time.h>
#include <wchar.h>
int main(void)
{
// Set up locale stuff...
setlocale(LC_ALL, "");
// Get current time
time_t simpletime = time(0);
// Break down time.
struct tm brokentime;
localtime_r(&simpletime, &brokentime);
// Normalise.
mktime(&brokentime);
fprintf (stdout, "asctime: %s", asctime(&brokentime));
// Print with strftime(3)
char buffer[40];
strftime(&buffer[0], 40, "%c", &brokentime);
fprintf (stdout, "strftime: %s\n", &buffer[0]);
wchar_t wbuffer[40];
wcsftime(&wbuffer[0], 40, L"%c", &brokentime);
fwide (stderr, 1);
fwprintf(stderr, L"wcsftime: %ls\n", &wbuffer[0]);
return 0;
}
- --
Roger Leigh
Printing on GNU/Linux? http://gimp-print.sourceforge.net/
Debian GNU/Linux http://www.debian.org/
GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>
iD8DBQFBp6lTVcFcaSW/uEgRApBiAKCstQ4rDG/1oTNDY69El0I1vIwP0gCffxMT
B3PQtf6lrIbXTLL+zhEfDTQ=
=v+s6
-----END PGP SIGNATURE-----
--
Linux-UTF8: i18n of Linux on all levels
Archive: http://mail.nl.linux.org/linux-utf8/