develooper Front page | perl.perl5.porters | Postings from August 2017

Re: my_strerror() as API function

Thread Previous | Thread Next
From:
Karl Williamson
Date:
August 18, 2017 23:11
Subject:
Re: my_strerror() as API function
Message ID:
adfba49f-d924-3273-8bf9-372925b1b318@khwilliamson.com
On 08/12/2017 11:55 AM, Zefram wrote:
> In scope of "use locale", my_strerror() returns a string encoded in the
> locale's charset.  $! uses a dodgy heuristic to sometimes decode this.

I have addressed any "dodginess" by

commit a8f4b0c691d6f1b08948976e74087b646bf8c6ef
  Author: Karl Williamson <khw@cpan.org>
  Date:   Fri Aug 18 13:46:25 2017 -0600

      Improve heuristic for UTF-8 detection in "$!"

      Previously, the stringification of "$!" was considered to be UTF-8 
if it
      had any characters with the high bit set, and everything was
      syntactically legal UTF-8.  This may incorrectly guess on short 
strings
      where there are only a few non-ASCII bytes.  This could happen in
      languages based on the Latin script where many words don't use
      non-ASCII.

      This commit adds a check that the locale is a UTF-8 one.  That 
check is
      a call to an already-existing subroutine which goes to some lengths to
      get an accurate answer, and should be essentially completely 
reliable on
      modern systems that have nl_langinfo() and/or mbtowc().

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