develooper Front page | perl.perl5.porters | Postings from June 2013

Re: [perl #118279] FAIL_OK is not defined in utf8

Thread Previous | Thread Next
From:
Eric Brine
Date:
June 3, 2013 17:10
Subject:
Re: [perl #118279] FAIL_OK is not defined in utf8
Message ID:
CALJW-qHS=1pSigWAzLygi907G_jyKW9oZRuUstv1_pa4DRhzXQ@mail.gmail.com
On Mon, Jun 3, 2013 at 9:25 AM, Father Chrysostomos via RT <
perlbug-followup@perl.org> wrote:

> It might be a break with tradition, but I think $fail_ok would be even
> clearer.
>

It's already using $variable notation rather than EXPR notation for the
first argument! I don't see any issue with changing

$success    = utf8::downgrade($string[, EXPR]);

to

$success    = utf8::downgrade($string[, $fail_ok]);

It's a common notation. It's already used elsewhere in that module. This
isn't perlfunc, so it's not inconsistent.


Note that utf8::is_utf8 and utf8::value are inconsistent and should be
fixed at the same time.

    use utf8;
    no utf8;

    # Convert the internal representation of a Perl scalar to/from UTF-8.

    $num_octets = utf8::upgrade($string);
    $success    = utf8::downgrade($string[, FAIL_OK]);

    # Change each character of a Perl scalar to/from a series of
    # characters that represent the UTF-8 bytes of each original character.

    utf8::encode($string);  # "\x{100}"  becomes "\xc4\x80"
    utf8::decode($string);  # "\xc4\x80" becomes "\x{100}"

    $flag = utf8::is_utf8(STRING); # since Perl 5.8.1
    $flag = utf8::valid(STRING);

I shall create a pair of patches immediately.

- Eric

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