i18n-discuss@opensolaris.org
[Top] [All Lists]

Re: [i18n-discuss] Fwd: wctrans(3C) not working in Solaris 11/B134 ?

Subject: Re: [i18n-discuss] Fwd: wctrans(3C) not working in Solaris 11/B134 ?
From: Jan Lana
Date: Tue, 14 Dec 2010 11:18:22 +0100
Hi Roland,

to use ja_JP.UTF-8 locale you have to call setlocale(3C) function first,
otherwise your code run in C locale (even if you set LC_*/LANG env
variables). With this patch

------------------------------------------------
--- test.c.orig 2010-12-14 12:09:06.035627838 +0100
+++ test.c      2010-12-14 12:05:19.215017921 +0100
@@ -1,12 +1,15 @@
 #include<stdlib.h>
 #include<stdio.h>
 #include<sys/localedef.h>
+#include <locale.h>
 
 int main(int ac, char *av[])
 {
        int i;
        printf("ntrans=%d\n", (int)__lc_ctype->ntrans);
 
+       printf("setlocale() = %s\n", setlocale(LC_ALL, "ja_JP.UTF-8"));
+
        for(i=1 ; i<= __lc_ctype->ntrans ; i++)
        {
                printf("i=%d\n", i);
@@ -21,3 +24,4 @@
 
        return EXIT_SUCCESS;
 }
------------------------------------------------

the output is 

ntrans=2
setlocale() = ja_JP.UTF-8
i=1
trans_index=1
trans_name=toupper
i=2
trans_index=2
trans_name=tolower
i=3
trans_index=3
trans_name=tojhira
i=4
trans_index=4
trans_name=tojkata
i=5
trans_index=5
trans_name=tojisx0201
i=6
trans_index=6
trans_name=tojisx0208
wctrans(tojhira)==3
wctrans(tojkata)==4
wctrans(tojisx0201)==5
wctrans(tojisx0208)==6

regards,
- jenda

On Mon, Dec 13, 2010 at 01:08:38PM +0100, Ales Cernosek wrote:
> -------- Pu*vodní zpráva --------
> Pr(edme(t:    [i18n-discuss] wctrans(3C) not working in Solaris 11/B134 ?
> Datum:        Mon, 29 Nov 2010 15:06:51 +0100
> Od:   Roland Mainz <roland.mainz@xxxxxxxxxxx>
> Komu:         i18n-discuss@xxxxxxxxxxxxxxx
> 
> 
> 
> Hi!
> 
> ----
> 
> Can anyone please confirm whether this is a bug:
> http://src.opensolaris.org/source/xref/nv-g11n/g11n/src/locale_src/base/include/CTYPE.ja_JP.UTF-8
> defines several character mappings, including "tojhira", "tojkata;
> "tojisx0201" and "tojisx0208". However if I try to use |wctrans()|
> always returns zero.
> 
> Example:
> -- snip --
> #include<stdlib.h>
> #include<stdio.h>
> #include<sys/localedef.h>
> 
> int main(int ac, char *av[])
> {
>        int i;
>        printf("ntrans=%d\n", (int)__lc_ctype->ntrans);
> 
>        for(i=1 ; i<= __lc_ctype->ntrans ; i++)
>        {
>                printf("i=%d\n", i);
>                printf("trans_index=%d\n", __lc_ctype->transname[i].index);
>                printf("trans_name=%s\n", __lc_ctype->transname[i].name);
>        }
> 
>        printf("wctrans(%s)==%ld\n", "tojhira", wctrans("tojhira"));
>        printf("wctrans(%s)==%ld\n", "tojkata", wctrans("tojkata"));
>        printf("wctrans(%s)==%ld\n", "tojisx0201", wctrans("tojisx0201"));
>        printf("wctrans(%s)==%ld\n", "tojisx0208", wctrans("tojisx0208"));
> 
>        return EXIT_SUCCESS;
> }
> -- snip --
> 
> Running this test prints this output:
> -- snip --
> $ cc -xs -g x.c -o x
> $ bash -c 'LC_ALL=ja_JP.UTF-8 ./x'
> ntrans=2
> i=1
> trans_index=1
> trans_name=toupper
> i=2
> trans_index=2
> trans_name=tolower
> wctrans(tojhira)==0
> wctrans(tojkata)==0
> wctrans(tojisx0201)==0
> wctrans(tojisx0208)==0
> -- snip --
> 
> Somehow it looks that |wctrans()| support beyond that defined by the
> standards is broken... right (it works on Linux (with slightly
> different mapping names)) ?
> 
> ----
> 
> Bye,
> Roland
> 
> -- 
>   __ .  . __
>  (o.\ \/ /.o) roland.mainz@xxxxxxxxxxx
>   \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
>   /O /==\ O\  TEL +49 641 3992797
>  (;O/ \/ \O;)
> _______________________________________________
> i18n-discuss mailing list
> i18n-discuss@xxxxxxxxxxxxxxx
> http://mail.opensolaris.org/mailman/listinfo/i18n-discuss
> 
_______________________________________________
i18n-discuss mailing list
i18n-discuss@xxxxxxxxxxxxxxx
http://mail.opensolaris.org/mailman/listinfo/i18n-discuss

<Prev in Thread] Current Thread [Next in Thread>
  • Re: [i18n-discuss] Fwd: wctrans(3C) not working in Solaris 11/B134 ?, Jan Lana <=