Opened 4 years ago

Last modified 4 years ago

#12303 new bug

nl_langinfo(CODESET) seems to always return US-ASCII whatever environment values

Reported by: oco Owned by: nobody
Priority: low Milestone: Unscheduled
Component: System/POSIX Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Has a Patch: no Platform: All

Description

My guess is that under Haiku, this function should return UTF-8.

I found a discussion about this in the haikuport mailling list : http://comments.gmane.org/gmane.os.haiku.ports.devel/1154.

But it is not clear for me what need to be done (or if there is something to do). Maybe, it is not worth the time.

Here is a sample program to test this function :

#include <stdio.h> #include <langinfo.h>

main() {

printf("%s\n", nl_langinfo(CODESET));

}

Here is a sample run :

/boot/src/fpc/tests> printenv LC_TYPE en_US.UTF-8 /boot/src/fpc/tests> nl_lang_info US-ASCII

Change History (2)

comment:1 Changed 4 years ago by pulkomandy

This ends up returning the charset computed in src/system/libroot/add-ons/icu/ICUCategoryData.cpp. I have no idea how the code there can end up saying "US-ASCII", however.

So it sounds like an actual bug.

comment:2 Changed 4 years ago by graemeg

I had a similar problem under FreeBSD 10.1 and my test program - just like yours - didn't call setlocale() before calling nl_langinfo(). Here is the corrected test code - which works now under FreeBSD. Just thought I would mention it, in case it fixes your issue under Haiku too.

/* Compile with "gcc48 -W -Wall -o langinfo langinfo_test.c" */
#include <stdio.h>
#include <langinfo.h>
#include <locale.h>

int main()
{
  setlocale(LC_ALL,"");
  printf("%s\n", nl_langinfo(CODESET));
  return 0;
}

Note: See TracTickets for help on using tickets.