Opened 9 years ago

Closed 3 years ago

#12303 closed bug (invalid)

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:
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 (3)

comment:1 by pulkomandy, 9 years ago

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 by graemeg, 9 years ago

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;
}

comment:3 by korli, 3 years ago

Resolution: invalid
Status: newclosed

The test from graemeg returns correctly UTF-8 on a current nightly, thus closing as invalid. The same test without setlocale() returns US-ASCII.

Note: See TracTickets for help on using tickets.