perl-unicode

Re: Encode, take five

2000-09-12 17:39:42
        bytes_to_utf8(STRING [, CHECK])

The bytes in STRING are encoded in-place into UTF-8.  The bytes are
assumed to be encoded in US-ASCII, bytes between 0 and 127, inclusive.
Returns the new size of STRING, or C<undef> if there's a failure.

Okay, now it's time for me to slow down.  Now I've come a full circle
back to reducing bytes_to_utf8() to being again equal to just turning
on the UTF-8 flag :-)  So if we limit bytes_to_utf8() to operate only
on 0..127, the bytes_to_utf8() becomes redundant.

If there are characters > 127?  See L</"Handling Malformed Data">.

If you want to recode some eight-bit legacy encoding to UTF-8, you
must use C<from_to(STRING, ..., 'utf8')>.

[INTERNAL] Also the UTF-8 flag of STRING is turned on.

=item *

        utf8_to_bytes(STRING [, CHECK])

The UTF-8 in STRING is decoded in-place into bytes.  Returns the new
size of STRING, or C<undef> if there's a failure.

This is still valid since the utf8 might be coming from somewhere
else than bytes_to_utf8() (assuming the above silly bytes_to_utf8()).

-- 
$jhi++; # http://www.iki.fi/jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen

<Prev in Thread] Current Thread [Next in Thread>