NAME

POSIX::Wide -- POSIX functions returning wide-char strings

SYNOPSIS

use POSIX::Wide;
print POSIX::Wide::strerror(2),"\n";
print POSIX::Wide::strftime("%a %d-%b\n",localtime());

DESCRIPTION

This is a few of the POSIX module functions adapted to return Perl wide-char strings instead of locale charset byte strings.

EXPORTS

Nothing is exported by default, but each of the functions and the $ERRNO and $EXTENDED_OS_ERROR variables can be imported in usual Exporter style. Eg.

use POSIX::Wide 'strftime', '$ERRNO';

There's no :all tag yet, as not sure if it would best import just the new funcs, or get everything from POSIX.

FUNCTIONS

$str = POSIX::Wide::localeconv ($format, ...)

Return a hashref of locale information

{ decimal_point => ...,
  grouping      => ...
}

Text field values are wide chars. Non-text fields like grouping and number fields like frac_digits are unchanged.

$str = POSIX::Wide::perror ($message)

Print $message and errno string $! to STDERR, with wide-chars for the errno string.

$message: $!\n
$str = POSIX::Wide::strerror ($errno)

Return a descriptive string for a given $errno number.

$str = POSIX::Wide::strftime ($format, $sec, $min, $hour, $mday, $mon, $year, ...)

Format a string of date-time parts. $format and the return are wide-char strings.

The current implementation passes ASCII parts of $format, including the "%" formatting directives, to strftime(). This means $format can include characters which might not exist in the locale charset.

($std_name, $dst_name) = POSIX::Wide::tzname ()

Return the tzname[] strings for standard time and daylight savings time as wide char strings.

The POSIX spec is that these should only have characters from the "portable character set", so normally the bytes of plain POSIX::tzname should suffice. POSIX::Wide::tzname can be used if someone might get creative with a TZ setting.

VARIABLES

$num = $POSIX::Wide::ERRNO + 0
$str = "$POSIX::Wide::ERRNO"

A magic dual-value variable which is $! but giving the string form as wide-chars (see "$ERRNO" in perlvar).

$num = $POSIX::Wide::EXTENDED_OS_ERROR + 0
$str = "$POSIX::Wide::EXTENDED_OS_ERROR"

A magic dual-value variable which is $^E but giving the string form as wide-chars (see "$EXTENDED_OS_ERROR" in perlvar).

The current implementation assumes $^E is locale bytes (if it isn't already wide). This is true of POSIX but not absolutely sure for MacOS and VMS.

WITH Errno::AnyString

Custom error strings set into $! by Errno::AnyString work with all of strerror, perror and $ERRNO above, and custom error numbers registered with Errno::AnyString can be accessed with strerror too.

If you use non-ASCII in such a string then it should be locale bytes the same as normal $! strings. If $! is a wide character string then <POSIX::Wide> will return that unchanged (though whether wide strings from $! would well with other code is another matter).

OTHER WAYS TO DO IT

Glib::Utils strerror() gives a wide char string similar to POSIX::Wide::strerror() above if you're using Glib.

Glib also has a g_date_strftime, which is not wrapped as of Perl-Glib 1.220 giving a utf8 strftime similar to POSIX::Wide::strftime above, but only for a date, not a date and time together.

SEE ALSO

POSIX, Glib::Utils (which includes a wide strsig)

HOME PAGE

http://user42.tuxfamily.org/i18n-langinfo-wide/index.html

LICENSE

I18N-Langinfo-Wide is Copyright 2008, 2009, 2010 Kevin Ryde

I18N-Langinfo-Wide is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

I18N-Langinfo-Wide is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with I18N-Langinfo-Wide. If not, see <http://www.gnu.org/licenses/>.