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

Re: my_strerror() as API function

Thread Previous | Thread Next
Karl Williamson
August 18, 2017 23:11
Re: my_strerror() as API function
Message ID:
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 <>
  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 
      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

      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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About