This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
[RFH] Trouble with mbsrtowcs and "\244" (Euro symbol)
- From: Paolo Carlini <pcarlini at unitus dot it>
- To: libc-alpha <libc-alpha at sources dot redhat dot com>
- Cc: Ulrich Drepper <drepper at redhat dot com>, bkoz <bkoz at redhat dot com>
- Date: Sun, 12 May 2002 23:51:34 +0200
- Subject: [RFH] Trouble with mbsrtowcs and "\244" (Euro symbol)
Hi,
working on libstdc++v3 monetary facets with Benjamin (Kosnik) we are
having trouble with wchar_t and non-ascii monetary symbols (see
libstdc++/6410). Benjamin could distillate the problem to the following
mostly "C" testcase:
#define _GNU_SOURCE 1
#include <locale.h>
#include <string.h>
#include <wchar.h>
#include <langinfo.h>
#include <malloc.h>
int main()
{
const char* __name = "de_DE@euro";
__locale_t __cloc = __newlocale(1 << LC_ALL, __name, 0);
char* __old = strdup(setlocale(LC_ALL, NULL));
setlocale(LC_ALL, __name);
//const char* __ccurr = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc);
const char* __ccurr = "\244";
mbstate_t __state;
size_t __result;
size_t __len = strlen(__ccurr);
wchar_t* __wcs;
if (__len)
{
++__len;
__wcs = new wchar_t[__len];
memset(&__state, 0, sizeof(mbstate_t));
__result = mbsrtowcs(__wcs, &__ccurr, __len, &__state);
}
setlocale(LC_ALL, __old);
delete [] __wcs;
free(__old);
}
What happens is that *__wcs turns out to be (unexpectedly to us) 6384,
whereas __ccurr = "\243" => *__wcs == 163 and __ccurr = "\245" => *__wcs
== 165.
What does 6384 mean?
Thanks for any help,
Paolo.
P.S. We are on glibc2.2.5, x86-Linux.