The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

    Unicode::Peek - Perl module supports different unicode(s) transformation
    formats to hex and vice versa.

VERSION

    Version 0.01

SYNOPSIS

    The Unicode::Peek - Perl module provides to the user the ability to encode/
    decode asccii strings in a variety of unicode transformations to hex and vice
    versa. The user is able to take a peek in the hex data and see the formatted
    output and also vise versa. The user can provided an array of data in a hex
    format and convert it back to ascii. Perl version 5.13.2 or greater is required.

SUBROUTINES/METHODS

    use Unicode::Peek ( 'ascii2hexEncode', 'hex2ascciiDecode',
                        'hexDumperOutput', 'hexDumperInput' );

    my $hexEncoded         = ascii2hexEncode($unicodeFormat, $ascciiCharacters);
    ...

    my $ascciiCharacters   = hex2ascciiDecode($unicodeFormat, $hexEncoded);
    ...

    my @hexFormattedOutput = hexDumperOutput($unicodeFormat, $ascciiCharacters);
    ...

    my $ascciiCharacters   = hexDumperInput($unicodeFormat, \@hexFormattedOutput);
    ...

DESCRIPTION

    This module exports four methods (ascii2hexEncode, hex2ascciiDecode, hexDumperOutput
    and hexDumperInput). All methods support 14 different encoding and decoding formats.
    The module has been tested with multiple languages with complex characters, but not
    with all known languages in the planet. So far as many languages have been tested all
    characters where encoded / decoded correctly.

EXPORT

    None by default, but the module can also export all methods by simple declaring all:

    use Unicode::Peek ':all';

SUPPORTED UNICODE FORMATS

  • UCS-2

  • UCS-2BE

  • UCS-2LE

  • UCS-4

  • UTF-7

  • utf8

  • utf8-strict

  • UTF-8

  • UTF-16

  • UTF-16BE

  • UTF-16LE

  • UTF-32

  • UTF-32BE

  • UTF-32LE

EXAMPLE 1 (hexDumperOutput)

    This example is for femonstration purposes, randomly choosen Chinese as a testing
    language. We will use the L<Data::Dumper|https://perldoc.perl.org/Data/Dumper.html> module to print the formated hex output. Necessary is also the L<utf8|https://perldoc.perl.org/utf8.html>
    for the stdout (convert the internal representation of a Perl scalar to/from UTF-8.)

    #!/usr/bin/perl
    use utf8;
    use strict;
    use warnings;
    use Data::Dumper;

    use Unicode::Peek qw( hexDumperOutput );

    my $lanquage = 'Chinese';

    my $str = '這是一個測試';

    my @flags = ( 'UCS-2',
                  'UCS-2BE',
                  'UCS-2LE',
                  'UCS-4',
                  'UTF-7',
                  'utf8',
                  'UTF-8',
                  'utf-8-strict',
                  'UTF-16',
                  'UTF-16BE',
                  'UTF-16LE',
                  'UTF-32',
                  'UTF-32BE',
                  'UTF-32LE' );

    while ( defined ( my $flag = shift @flags ) ) {
        print Dumper hexDumperOutput($flag, $str);
    };

EXAMPLE 2 (hexDumperInput)

    #!/usr/bin/perl
    use utf8;
    use strict;
    use warnings;
    use Data::Dumper;
    use feature 'say';

    use Unicode::Peek qw( hexDumperOutput hexDumperInput );

    my $lanquage = 'Chinese';

    my $str = '這是一個測試';

    my @flags = ( 'UCS-2',
                  'UCS-2BE',
                  'UCS-2LE',
                  'UCS-4',
                  'UTF-7',
                  'utf8',
                  'UTF-8',
                  'utf-8-strict',
                  'UTF-16',
                  'UTF-16BE',
                  'UTF-16LE',
                  'UTF-32',
                  'UTF-32BE',
                  'UTF-32LE' );

    while ( defined ( my $flag = shift @flags ) ) {
        my $hexDumper = hexDumperOutput($flag, $str);
        print Dumper $hexDumper;
        say hexDumperInput($flag, $hexDumper);
    };

EXAMPLE 3 (hex2ascciiDecode ascii2hexEncode)

    #!/usr/bin/perl
    use utf8;
    use strict;
    use warnings;
    use feature 'say';

    use Unicode::Peek qw( hex2ascciiDecode ascii2hexEncode );

    my $lanquage = 'Chinese';

    my $str = '這是一個測試';

    my @flags = ( 'UCS-2',
                  'UCS-2BE',
                  'UCS-2LE',
                  'UCS-4',
                  'UTF-7',
                  'utf8',
                  'UTF-8',
                  'utf-8-strict',
                  'UTF-16',
                  'UTF-16BE',
                  'UTF-16LE',
                  'UTF-32',
                  'UTF-32BE',
                  'UTF-32LE' );

     while ( defined ( my $flag = shift @flags ) ) {
         my $hexEncoded = ascii2hexEncode($flag, $str);
         say hex2ascciiDecode($flag, $hexEncoded);
     };

DEPENDENCIES

    The module is implemented by using 'utf8' and 'Encode', both modules are
    mandatory as prerequisites and required to be pre-installed.

AUTHOR

Athanasios Garyfalos, Egaryfalos@cpan.org

BUGS

    Please report any bugs or feature requests to C<bug-unicode-peek at rt.cpan.org>, or through
    the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Unicode-Peek>.  I will be notified, and then you'll
    automatically be notified of progress on your bug as I make changes.

SUPPORT

    You can find documentation for the module with the perldoc command.

    perldoc Unicode::Peek
  • RT: CPAN's request tracker (report bugs here)

    L
  • AnnoCPAN: Annotated CPAN documentation

    L
  • CPAN Ratings

    L
  • Search CPAN

    L

SEE ALSO

perl, L, L and L

REPOSITORY

L
    This library is free software; you can redistribute it and/or modify it under
    the same terms as Perl itself.

COPYRIGHT AND LICENSE

    Copyright (C) 2017 by Athanasios Garyfalos.

    This library is free software; you can redistribute it and/or modify it
    under the terms of the the Artistic License (2.0). You may obtain a
    copy of the full license at:
L
    Any use, modification, and distribution of the Standard or Modified
    Versions is governed by this Artistic License. By using, modifying or
    distributing the Package, you accept this license. Do not use, modify,
    or distribute the Package, if you do not accept this license.

    If your Modified Version has been derived from a Modified Version made
    by someone other than you, you are nevertheless required to ensure that
    your Modified Version complies with the requirements of this license.

    This license does not grant you the right to use any trademark, service
    mark, tradename, or logo of the Copyright Holder.

    This license includes the non-exclusive, worldwide, free-of-charge
    patent license to make, have made, use, offer to sell, sell, import and
    otherwise transfer the Package with respect to any patent claims
    licensable by the Copyright Holder that are necessarily infringed by the
    Package. If you institute patent litigation (including a cross-claim or
    counterclaim) against any party alleging that the Package constitutes
    direct or contributory patent infringement, then this Artistic License
    to you shall terminate on the date that such litigation is filed.

    Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
    AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
    THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
    PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
    YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
    CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
    CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
    EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

CHANGE LOG

    $Log: Peek.pm,v $
    Revision 0.01  2017/09/21 17:22:21 (UCT) Thanos