develooper Front page | perl.perl5.porters | Postings from April 2018

Re: [perl #133157] Solaris Failing Some Locale Tests

Thread Previous | Thread Next
From:
Karl Williamson
Date:
April 28, 2018 04:24
Subject:
Re: [perl #133157] Solaris Failing Some Locale Tests
Message ID:
43642bef-e3f9-3857-ddbe-14092fa85df3@khwilliamson.com
On 04/27/2018 09:56 PM, Carlos Guevara wrote:
> Revised radix.c:
> #####
> #include <stdio.h>
> #include <locale.h>
> 
> int
> main(int argc, char ** argv)
> {
>      unsigned char buf[100];
>      unsigned int i;
> 
>      printf("%s\n", setlocale(LC_ALL, "ar_AE.UTF-8"));
>      snprintf(buf, sizeof(buf), "%g", 3.2);
> 
>      for (i = 0; i < sizeof(buf); i++) {
>          if (buf[i] == '\0') break;
>          printf(" %x", buf[i]);
>      }
>      printf("\n");
> }
> #####
> 
> Output:
> #####
> ar_AE.UTF-8
>   33 d9 32
> #####
> 

That should instead have been 33 d9 ab 32.
And that indicates that the problem is indeed with the OS.
My guess is that it doesn't consider the possibility of a multi-byte 
radix character, so it uses just the first byte, but \xd9 is a start 
byte of a two byte sequence, so this is leading to malformed UTF-8.

I'll submit a trouble ticket for them.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About