Hi Takashi, On Sep 3 01:25, Takashi Yano via Cygwin-patches wrote: > Hi Corinna, > > On Wed, 2 Sep 2020 17:24:50 +0200 > Corinna Vinschen wrote: > > > > get_locale_from_env() and get_langinfo() should go away. If we just > > > > need a codepage for get_ttyp ()->term_code_page, we should really find a > > > > way to do this from within internal_setlocale(). > > > > > > I looked into internal_setlocale() code, but I could not found > > > the code which handles thecode page. I found the code handling > > > the code page in __set_charset_from_locale() function in nlsfuncs.cc, > > > but it does not return code page itself. Could you please explain > > > more detail of your idea? > > > > I had none yet :) I was just musing, without actually thinking about a > > solution. But I think this isn't very complicated. Given this is > > inside Cygwin, nothing keeps the function to have a well-defined > > side-effect, as in setting a (not yet existing) member "term_code_page" > > of cygheap->locale. > > > > Kind of like this: > > [...] > I have tried your code, however, it does not work as expected. > It seems that __set_charset_from_locale() is not called. > cygheap->locale.term_code_page is always 0.
Ah, right! Take a look into newlib/libc/locale/locale.c, function __loadlocale(). This function is called from _setlocale_r(). However, it calls __set_charset_from_locale() *only* if the charset isn't already given explicitely in the LC_* or LANG string, because otherwise we already know the charset, after all. Darn! That foils my plans for world domination... > Let me consider a while. Thanks, I'll do the same. I'd really like to simplify this stuff and doing the locale shuffle in two entirely different locations at different times is prone to getting out of sync. Corinna