[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: Desperate in need of help: Very very weird problem with sscanf
From: Thiago Macieira <thiago () kde ! org>
Date: 2009-08-20 15:04:41
Message-ID: 200908201704.42184.thiago () kde ! org
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
Em Quinta-feira 20 Agosto 2009, às 10:06:19, você escreveu:
> For the interested parties: I added an issue to tesseract. I hope I did sta
> te the matter correctly:
>
> http://code.google.com/p/tesseract-ocr/issues/detail?id=236
Technically, this is not about resetting. It's just about using locale-
dependent functions with locale-independent data. They have to solve that
problem: they should use functions not affected by the locale.
What's more, it's not just KDE. *Most* programs that have user-interaction
call setlocale(3). The example below illustrates:
$ cat /tmp/sscanf.c
#include <stdio.h>
#include <locale.h>
void execute(const char *stage)
{
static const char string[] = "-0.25000 0.75000";
float f1, f2;
sscanf(string, "%f %f", &f1, &f2);
printf("%s: %f %f\n", stage, f1, f2);
}
int main()
{
/* before we call setlocale(3), the C library defaults to "C" */
execute("before");
/* calling setlocale to initialise libc's locale subsystem.
* This sets the locale to the user's environment.
* In my case, that's pt_BR.UTF-8 */
setlocale(LC_ALL, "");
execute("user locale");
/* We can force the "C" locale */
setlocale(LC_ALL, "C");
execute("\"C\" locale");
}
$ /tmp/sscanf
before: -0.250000 0.750000
user locale: -0,000000 0,000000
"C" locale: -0.250000 0.750000
The problem is that the C library has no such locale-independent function.
Even strtod/strtof are dependent.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Senior Product Manager - Nokia, Qt Development Frameworks
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
Qt Developer Days 2009 | Registration Now Open!
Munich, Germany: Oct 12 - 14 San Francisco, California: Nov 2 - 4
http://qt.nokia.com/qtdevdays2009
["signature.asc" (application/pgp-signature)]
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic