[ghemical-devel] LC_NUMERIC problem

Jean Bréfort jean.brefort@ac-dijon.fr
09 Feb 2004 13:31:40 +0100


--=-RE+OM496n/Y5leC5RxAw
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Le lun 09/02/2004 =C3=A0 08:52, Tommi Hassinen a =C3=A9crit :
> Hi,
>=20
> and thanks for pointing out this issue; I know this is not working yet
> properly.
>=20
> In my opinion, it is not sufficient just to set the local locale settings
> and use them ; for example you might download a file from another
> continent, saved using different locale settings, so it won't work. So I
> guess the only way to be 100% sure about localization is to save the
> locale information into the file itself.
>=20
> So in terms of the .gpr file format, we could add a new section
>=20
> 	!Locale "C"
>=20
> or perhaps include it into the current header section:
>=20
> 	!Header gpr 110
> ->	!Header gpr 110 "C"
>=20
> So when a file is saved, the locales used would be saved with the file,
> and then later used to read in the file. I'll try this some day this week=
.
>=20

I do not believe this is a good idea. Generally, programs save and load
files in C locale, at least for numerical data. So there is no
compatibility problem. Here is how it works :

char *	old_num_locale =3D g_strdup(setlocale(LC_NUMERIC, NULL));
setlocale(LC_NUMERIC, "C");

/* Here save or load data */

setlocale(LC_NUMERIC, old_num_locale);
g_free(old_num_locale);

Note that this use GLib calls. Probably strdup and free also work.
Sometimes, the time locale must also be changed (if the time of
creation/revision of the file must be saved with the data).

Best regards,

Jean


--=-RE+OM496n/Y5leC5RxAw
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: Ceci est une partie de message
	=?ISO-8859-1?Q?num=E9riquement?= =?ISO-8859-1?Q?_sign=E9e?=

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQBAJ32rUkVLHK5zOkcRAg7LAKCyXGsDCFVkkM7Mcj/Q5/5NpupuagCffY5r
1x4Rw3alxTRVkrRJxYITRkU=
=1MEx
-----END PGP SIGNATURE-----

--=-RE+OM496n/Y5leC5RxAw--