GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  BADGER::CODEC::UNICODE (3)

.ds Aq ’

NAME

Badger::Codec::Unicode - encode/decode Unicode

CONTENTS

SYNOPSIS



    use Badger::Codec::Unicode;
    my $codec   = Badger::Codec::Unicode->new();
    my $uncoded = "...some Unicode data...";
    my $encoded = $codec->encode($uncoded);
    my $decoded = $codec->decode($encoded);



DESCRIPTION

This module is a subclass of Badger::Codec implementing a very thin wrapper around the Encode module for encoding and decoding Unicode.

A Badger::Codec::Unicode object provides the encode() and decode() methods for encoding and decoding Unicode.



    use Badger::Codec::Unicode;
    my $codec   = Badger::Codec::Unicode->new();
    my $uncoded = "...some Unicode data...";
    my $encoded = $codec->encode($uncoded);
    my $decoded = $codec->decode($encoded);



You can also call encode() and decode() as class methods.



    my $encoded = Badger::Code::Unicode->encode($uncoded);
    my $decoded = Badger::Code::Unicode->decode($encoded);



You can also use a codec via the Badger::Codecs module.



    use Badger::Codecs
        codec => unicode;



This exports the encode() and decode() subroutines.



    my $uncoded  = "...some Unicode data...";
    my $encoded  = encode($uncoded);
    my $decoded  = decode($encoded)



METHODS

encode($encoding, CW$data)

Method for encoding Unicode data. If two arguments are provided then the first is the encoding and the second the data to encode.



    $encoded = $codec->encode( utf8 => $data );



If one argument is provided then the encoding defaults to UTF-8.



    $utf8 = $codec->encode($data);



decode($encoding, CW$data)

Method for decoding Unicode data. If two arguments are provided then the first is the encoding and the second the data to decode.



    $decoded = $codec->decode( utf8 => $encoded );



If one argument is provided then the method will look for a Byte Order Mark (BOM) to determine the encoding. If a BOM isn’t present, or if the BOM doesn’t match a supported Unicode BOM (any of UTF-8, UTF-32BE UTF-32LE, UTF-16BE or UTF-16LE) then the data will not be decoded as Unicode.



    $decoded = $codec->decode($encoded);    # use BOM to detect encoding



encoder()

This method returns a subroutine reference which can be called to encode Unicode data. Internally it calls the encode() method.



    my $encoder = $codec->encode;
    $encoded = $encoder->($data);



decoder()

This method returns a suboroutine reference which can be called to decode Unicode data. Internally it calls the decode() method.



    my $decoder = $codec->decode;
    $decoded = $decoder->($data);



AUTHOR

Andy Wardley <http://wardley.org/>

COPYRIGHT

Copyright (C) 2005-2009 Andy Wardley. All rights reserved.

SEE ALSO

Encode, Badger::Codec::Encode, Badger::Codecs, Badger::Codec.
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 BADGER::CODEC::UNICODE (3) 2010-02-20

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.