OpenWrt Forum Archive

Topic: How to enable locale support?

The content of this topic has been archived on 11 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello,

I compile CC from source using the following .config:

CONFIG_TARGET_ar71xx=y
CONFIG_TARGET_ar71xx_generic=y
CONFIG_TARGET_ar71xx_generic_GLINET=y
CONFIG_DEVEL=y
CONFIG_BUILD_NLS=y
CONFIG_SDK=y
CONFIG_PACKAGE_iconv=y
CONFIG_PACKAGE_libcharset=y
CONFIG_PACKAGE_libiconv-full=y
CONFIG_PACKAGE_libintl-full=y
CONFIG_PACKAGE_kmod-fs-nfs=y
CONFIG_PACKAGE_nfs-utils=y

Then I run the following program

#include <wchar.h>
#include <locale.h>
int main(void)
{
  setlocale(LC_CTYPE, "C.UTF-8");
  wprintf(L"привет мир\n");
  return 0;
}

(on Debian 9 this program runs OK)
I get this output

Invalid wide format string.

Also, "locale" command does not exist.

Which config options must be set to enable uclibc locale support?

What is curious:
1) if we use "hello world" instead of "привет мир" - it works OK
2) if I use getwc() on non-ascii file (on ascii file it works OK), it fails with "getwc: Invalid or incomplete multibyte or wide character" (input is valid UTF-8 and works OK on Debian 9)

(Last edited by igor.liferenko on 15 Mar 2017, 10:12)

I tried the same programs in trunk and it works OK (commit 871372c42a3fc9c4b33f5c6011742d610a2e5600).

I also added these build options to be able to type UTF-8 characters in terminal:

CONFIG_BUSYBOX_CUSTOM=y
CONFIG_BUSYBOX_CONFIG_LAST_SUPPORTED_WCHAR=0
CONFIG_BUSYBOX_CONFIG_LOCALE_SUPPORT=y
CONFIG_BUSYBOX_CONFIG_SUBST_WCHAR=65533
CONFIG_BUSYBOX_CONFIG_UNICODE_PRESERVE_BROKEN=y
CONFIG_BUSYBOX_CONFIG_UNICODE_SUPPORT=y
CONFIG_BUSYBOX_CONFIG_UNICODE_USING_LOCALE=y
CONFIG_PACKAGE_kmod-nls-utf8=y

(I just enabled everything, so some options may be unnecessary - feedback welcome)

(Last edited by igor.liferenko on 17 Mar 2017, 03:02)

It turns out that the example program works in Designated Driver with default .config - no special options mentioned above are necessary (the reason is that musl is used instead of uClibc by default).

The discussion might have continued from here.