# setting LC_ALL to it's current value during startup

- Thread: https://externals.io/message/9936
- Original archive: https://news-web.php.net/php.internals/9936
- Started by Antony Dovgal on 2004-05-18T12:21:43+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #9936 — Antony Dovgal — 2004-05-18T12:21:43+00:00

URL: https://externals.io/message/9936#9936

Hi all!

Could somebody explain me why we're setting only `LC_CTYPE` to it's current value in main/main.c, line 1368 ?
What is the reason to make all users to call `setlocale()` explicitly to set `LC_ALL` ?

Of course, there can be some reasons I'm unaware of, but I'd like to propose following tiny patch:

Index: main.c
===================================================================
RCS file: /repository/php-src/main/main.c,v
retrieving revision 1.601
diff -u -r1.601 main.c
--- main.c      24 Mar 2004 13:33:26 -0000      1.601
+++ main.c      18 May 2004 12:14:12 -0000
@@ -1365,7 +1365,7 @@
        PG(disable_classes) = NULL;

 #if HAVE_SETLOCALE
-       setlocale(LC_CTYPE, "");
+       setlocale(LC_ALL, "");
 #endif

---
WBR,
Antony Dovgal aka tony2001
tony2001@phpclub.net || antony@dovgal.com

---

## #9938 — Wez Furlong — 2004-05-18T12:55:18+00:00

URL: https://externals.io/message/9936#9938 · In reply to: #9936

Hey Antony,

This is most likely due to some issues with serialize/unserialize and floating
point numbers; we don't want the format to change with the locale, since it
should be independent.

Yes, it is a mess :)

--Wez. 

> -----Original Message-----
> From: Antony Dovgal [mailto:tony2001@phpclub.net] 
> Sent: 18 May 2004 13:22
> To: php-dev
> Subject: [PHP-DEV] setting `LC_ALL` to it's current value during startup
> 
> Hi all!
> 
> Could somebody explain me why we're setting only `LC_CTYPE` to 
> it's current value in main/main.c, line 1368 ?
> What is the reason to make all users to call `setlocale()` 
> explicitly to set `LC_ALL` ?
> 
> Of course, there can be some reasons I'm unaware of, but I'd 
> like to propose following tiny patch:
> 
> Index: main.c
> ===================================================================
> RCS file: /repository/php-src/main/main.c,v
> retrieving revision 1.601
> diff -u -r1.601 main.c
> --- main.c      24 Mar 2004 13:33:26 -0000      1.601
> +++ main.c      18 May 2004 12:14:12 -0000
> @@ -1365,7 +1365,7 @@
>         PG(disable_classes) = NULL;
> 
>  #if HAVE_SETLOCALE
> -       setlocale(LC_CTYPE, "");
> +       setlocale(LC_ALL, "");
>  #endif
> 
> ---
> WBR,
> Antony Dovgal aka tony2001
> tony2001@phpclub.net || antony@dovgal.com

---

## #9941 — Antony Dovgal — 2004-05-18T13:09:42+00:00

URL: https://externals.io/message/9936#9941 · In reply to: #9938

On Tue, 18 May 2004 13:55:18 +0100
"Wez Furlong" <wez@thebrainroom.com> wrote:

> Hey Antony,
> 
> This is most likely due to some issues with serialize/unserialize and floating
> point numbers; we don't want the format to change with the locale, since it
> should be independent.
> 
> Yes, it is a mess :)

ok. 
but in this case we can set all except `LC_NUMERIC` and it should not affect floats.
so, the patch should look like this:

Index: main.c
===================================================================
RCS file: /repository/php-src/main/main.c,v
retrieving revision 1.601
diff -u -r1.601 main.c
--- main.c      24 Mar 2004 13:33:26 -0000      1.601
+++ main.c      18 May 2004 13:08:18 -0000
@@ -1365,7 +1365,12 @@
        PG(disable_classes) = NULL;

 #if HAVE_SETLOCALE
+       setlocale(LC_COLLATE, "");
        setlocale(LC_CTYPE, "");
+       setlocale(LC_MESSAGES, "");
+       setlocale(LC_MONETARY, "");
+       setlocale(LC_TIME, "");
+       /* `LC_NUMERIC` is not set due to some issues with serialize/unserialize */
 #endif

 #if HAVE_TZSET

---
WBR,
Antony Dovgal aka tony2001
tony2001@phpclub.net || antony@dovgal.com

---

## #10077 — Antony Dovgal — 2004-05-25T11:34:40+00:00

URL: https://externals.io/message/9936#10077 · In reply to: #9941

Could anybody comment this patch, please ?


On Tue, 18 May 2004 17:09:42 +0400
Antony Dovgal <tony2001@phpclub.net> wrote:
> On Tue, 18 May 2004 13:55:18 +0100
> "Wez Furlong" <wez@thebrainroom.com> wrote:
> 
> > […]
> 
> ok. 
> but in this case we can set all except `LC_NUMERIC` and it should not affect floats.
> so, the patch should look like this:
> 
> Index: main.c
> ===================================================================
> RCS file: /repository/php-src/main/main.c,v
> retrieving revision 1.601
> diff -u -r1.601 main.c
> --- main.c      24 Mar 2004 13:33:26 -0000      1.601
> +++ main.c      18 May 2004 13:08:18 -0000
> @@ -1365,7 +1365,12 @@
>         PG(disable_classes) = NULL;
> 
>  #if HAVE_SETLOCALE
> +       setlocale(LC_COLLATE, "");
>         setlocale(LC_CTYPE, "");
> +       setlocale(LC_MESSAGES, "");
> +       setlocale(LC_MONETARY, "");
> +       setlocale(LC_TIME, "");
> +       /* `LC_NUMERIC` is not set due to some issues with serialize/unserialize */
>  #endif
> 
>  #if HAVE_TZSET


---
WBR,
Antony Dovgal aka tony2001
tony2001@phpclub.net || antony@dovgal.com
