[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] fix locale string reading

From: Nala Ginrut
Subject: Re: [PATCH] fix locale string reading
Date: Wed, 9 Nov 2011 10:59:55 +0800

On Tue, Nov 8, 2011 at 9:31 PM, Peter Brett <address@hidden> wrote:
Nala Ginrut <address@hidden> writes:

> Here is the patch. It solved the problem like these:
> @@ -1532,6 +1533,7 @@ scm_from_locale_string (const char *str)
>  SCM
>  scm_from_locale_stringn (const char *str, size_t len)
>  {
> +  setlocale (LC_ALL, "");
>    return scm_from_stringn (str, len, locale_charset (),
>                             scm_i_get_conversion_strategy (SCM_BOOL_F));
>  }
> @@ -1758,6 +1760,7 @@ scm_to_locale_string (SCM str)
>  char *
>  scm_to_locale_stringn (SCM str, size_t *lenp)
>  {
> +  setlocale (LC_ALL, "");
>    return scm_to_stringn (str, lenp, 
>                           locale_charset (),
>                           scm_i_get_conversion_strategy (SCM_BOOL_F));

This patch *breaks* scm_to_locale_string() and
scm_from_locale_string().  The documentation for these functions quite
clearly states that they use "the current locale", not "the locale
specified by the environment variables". Not to mention the fact that
they change the current locale without restoring it afterwards.

NO, I don't agree.
setlocale(LC_ALL ,"") means the current locale is only queried, not modified. 
So it just make sure that locale_charset() can get the correct locale ,not a modified locale.

I tested this in C code. Current locale is "zh_CN.UTF-8",  locale_charset() will return "ANSI_X3.4-1968". 
It's definitely wrong. We must use setlocale(LC_ALL,"") to query current locale first, and locale_charset() will return "zh_CN.UTF-8".

reply via email to

[Prev in Thread] Current Thread [Next in Thread]