Re: Disabling localisation for an app
- From: "Søren Hauberg" <hauberg gmail com>
- To: "Paul Davis" <paul linuxaudiosystems com>
- Cc: gtkmm-list <gtkmm-list gnome org>
- Subject: Re: Disabling localisation for an app
- Date: Thu, 16 Oct 2008 15:08:55 +0200
2008/10/16 Paul Davis <paul linuxaudiosystems com>:
> you need to ensure that a portable locale is used when using stdio
> calls. my preferred method is this little class. Put one of this in any
> scope where you do stdio (input or output) and the locale is switched
> and then automatically restored when leaving the scope.
>
> struct LocaleGuard {
> LocaleGuard (const char*);
> ~LocaleGuard ();
> const char* old;
> };
>
> LocaleGuard::LocaleGuard (const char* str)
> {
> old = strdup (setlocale (LC_NUMERIC, NULL));
> if (strcmp (old, str)) {
> setlocale (LC_NUMERIC, str);
> }
> }
>
> LocaleGuard::~LocaleGuard ()
> {
> setlocale (LC_NUMERIC, old);
> free ((char*)old);
> }
Thanks. I didn't know the 'setlocale' function, which was the one I
needed. I've just added a 'setlocale (LC_ALL, "C");' to my code, as I
don't want any locale changes anywhere in the application.
Thanks,
Søren
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]