[prev in list] [next in list] [prev in thread] [next in thread]
List: bash-bug
Subject: Re: printf %d $'"\xff' returns random values in UTF-8 and 0 in C locale
From: Chet Ramey <chet.ramey () case ! edu>
Date: 2017-09-17 22:05:55
Message-ID: f8ea1394-b2c8-316b-f64a-b007828045af () case ! edu
[Download RAW message or body]
On 9/17/17 6:01 AM, Stephane Chazelas wrote:
> $ locale charmap
> UTF-8
> $ bash -c '"$@"' sh printf '%d\n' $'"\xff' $'"\xff' $'"\xff'
> 32767
> 0
> 0
>
> That's because we store the return value of mblen() (which may be
> -1) into a size_t (unsigned) variable.
>
> See patch below which aligns the behaviour with that of other
> shells which use the byte value when the initial sequence of
> bytes can't be converted to a character.
Thanks for the report. I'll take a look.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic