charset issue on Windows help needed
- From: Geert Janssens <info kobaltwit be>
- To: gtk-app-devel-list gnome org
- Subject: charset issue on Windows help needed
- Date: Wed, 10 Sep 2014 19:37:28 +0200
Hi,
I'm stuck on the following issue. Program is GnuCash on Windows.
Consider the following code snippet:
struct stat statbuf;
gchar* dirname = g_strdup(g_getenv("GNC_DOTGNUCASH_DIR");
gint rc = g_stat (dirname, &statbuf);
switch (errno)
{
case ENOENT:
// Directory doesn't exist
// Here is code to create it which I cut for brevity
break;
case EACCES:
// Directory can't be accessed
exit(1);
case ENOTDIR:
// Not a directory
exit(1);
default:
// Unknown error
exit(1);
}
// Continue code with valid, existing directory
...
So this snippet reads the value of environment variable GNC_DOTGNUCASH_DIR and tests
whether this is a valid directory.
This works fine when GNC_DOTGNUCASH_DIR uses a limited character set like ascii. For
example when set to "c:\gcdev\geert" this works well and the code continues.
However if set to for example:
c:\gcdev\Łukasz
Things go wrong (note the unusual Ł).
In this case the code branches into case ENOENT and creates a directory named
c:\gcdev\Lukasz (note the plain L now)
Before it continues.
Setting a breakpoint at rc=g_stat... and examining the value of dirname at that point also
shows it to have a value of c:\gcdev\Lukasz (with plain L).
So it seems I'm losing diacritical information here and I can't pass the right directory to my code
to use.
What should I do to get the real value from the environment to be able to access the true
directory ?
Thanks,
Geert
P.S. my locale settings are all "Dutch_Belgium.1252" except for LC_ALL which is empty.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]