NAME

Mojo::ByteStream - ByteStream

SYNOPSIS

    use Mojo::ByteStream;

    my $stream = Mojo::ByteStream->new('foobarbaz');

    $stream->camelize;
    $stream->decamelize;
    $stream->b64_encode;
    $stream->b64_decode;
    $stream->encode('UTF-8');
    $stream->decode('UTF-8');
    $stream->html_escape;
    $stream->html_unescape;
    $stream->md5_sum;
    $stream->qp_encode;
    $stream->qp_decode;
    $stream->quote;
    $stream->unquote;
    $stream->url_escape;
    $stream->url_sanitize;
    $stream->url_unescape;
    $stream->xml_escape;
    $stream->punycode_encode;
    $stream->punycode_decode;

    my $size = $stream->size;

    my $stream2 = $stream->clone;
    print $stream2->to_string;

    # Chained
    my $stream = Mojo::ByteStream->new('foo bar baz')->quote;
    $stream = $stream->unquote->encode('UTF-8)->b64_encode;
    print "$stream";

    # Constructor alias
    use Mojo::ByteStream 'b';

    my $stream = b('foobarbaz')->html_escape;

    # Buffering
    my $stream = Mojo::ByteStream->new;
    $stream->add_chunk('bar');
    my $foo = $stream->remove(3);
    my $bar = $stream->empty;

DESCRIPTION

Mojo::ByteStream provides portable text and bytestream manipulation functions.

Mojo::ByteStream implements the following attributes.

raw_size

    my $size = $stream->raw_size;
    $stream  = $stream->raw_size(23);

METHODS

Mojo::ByteStream inherits all methods from Mojo::Base and implements the following new ones.

new

    my $stream = Mojo::ByteStream->new($string);

add_chunk

    $stream = $stream->add_chunk('foo');

b64_decode

    $stream = $stream->b64_decode;

b64_encode

    $stream = $stream->b64_encode;

camelize

    $stream = $stream->camelize;

clone

    my $stream2 = $stream->clone;

contains

    my $position = $stream->contains('something');

decamelize

    $stream = $stream->decamelize;

decode

    $stream = $stream->decode($encoding);

empty

    my $chunk = $stream->empty;

encode

    $stream = $stream->encode($encoding);

get_line

   my $line = $stream->get_line;

html_escape

    $stream = $stream->html_escape;

html_unescape

    $stream = $stream->html_unescape;

md5_sum

    $stream = $stream->md5_sum;

punycode_decode

    $stream = $stream->punycode_decode;

punycode_encode

    $stream = $stream->punycode_encode;

qp_decode

    $stream = $stream->qp_decode;

qp_encode

    $stream = $stream->qp_encode;

quote

    $stream = $stream->quote;

remove

    my $chunk = $stream->remove(4);
    my $chunk = $stream->remove(4, 'abcd');

size

    my $size = $stream->size;

to_string

    my $string = $stream->to_string;

unquote

    $stream = $stream->unquote;

url_escape

    $stream = $stream->url_escape;
    $stream = $stream->url_escape('A-Za-z0-9\-\.\_\~');

url_sanitize

    $stream = $stream->url_sanitize;

url_unescape

    $stream = $stream->url_unescape;

xml_escape

    $stream = $stream->xml_escape;

SEE ALSO

Mojolicious, Mojolicious::Book, http://mojolicious.org.