PerlIO-bom
view release on metacpan or search on metacpan
use Module::Build 0.28;
my %module_build_args = (
"build_requires" => {
"Module::Build" => "0.28"
},
"configure_requires" => {
"Module::Build" => "0.28"
},
"dist_abstract" => "Automatic BOM handling in Unicode IO",
"dist_author" => [
"Leon Timmermans <leont\@cpan.org>"
],
"dist_name" => "PerlIO-bom",
"dist_version" => "0.001",
"license" => "perl",
"module_name" => "PerlIO::bom",
"recursive_test_files" => 1,
"requires" => {
"PerlIO::utf8_strict" => 0,
{
"abstract" : "Automatic BOM handling in Unicode IO",
"author" : [
"Leon Timmermans <leont@cpan.org>"
],
"dynamic_config" : 0,
"generated_by" : "Dist::Zilla version 6.015, CPAN::Meta::Converter version 2.150010",
"license" : [
"perl_5"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
---
abstract: 'Automatic BOM handling in Unicode IO'
author:
- 'Leon Timmermans <leont@cpan.org>'
build_requires:
Encode: '0'
Module::Build: '0.28'
Test::More: '0.89'
utf8: '0'
configure_requires:
Module::Build: '0.28'
dynamic_config: 0
This archive contains the distribution PerlIO-bom,
version 0.001:
Automatic BOM handling in Unicode IO
This software is copyright (c) 2015 by Leon Timmermans.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
This README file was generated by Dist::Zilla::Plugin::Readme v6.015.
lib/Linux/ppport.h view on Meta::CPAN
blk_u16|5.011000||Viu
block_end|5.004000|5.004000|
block_gimme|5.004000|5.004000|u
blockhook_register|5.013003|5.013003|x
block_start|5.004000|5.004000|
BmFLAGS|5.009005||Viu
BmPREVIOUS|5.003007||Viu
BmRARE|5.003007||Viu
BmUSEFUL|5.003007||Viu
BOL|5.003007||Viu
BOM_UTF8|5.025005|5.003007|p
BOM_UTF8_FIRST_BYTE|5.019004||Viu
BOM_UTF8_TAIL|5.019004||Viu
bool|5.003007||Viu
boolSV|5.004000|5.003007|p
boot_core_mro|5.009005||Viu
boot_core_PerlIO|5.007002||Viu
boot_core_UNIVERSAL|5.003007||Viu
BOUND|5.003007||Viu
BOUNDA|5.013009||Viu
BOUNDL|5.004000||Viu
BOUNDU|5.013009||Viu
BRANCH|5.003007||Viu
lib/Linux/ppport.h view on Meta::CPAN
#ifndef isUTF8_CHAR
# define isUTF8_CHAR(s, e) ( \
(e) <= (s) || ! is_utf8_string(s, UTF8_SAFE_SKIP(s, e)) \
? 0 \
: UTF8SKIP(s))
#endif
#endif
#if 'A' == 65
#ifndef BOM_UTF8
# define BOM_UTF8 "\xEF\xBB\xBF"
#endif
#ifndef REPLACEMENT_CHARACTER_UTF8
# define REPLACEMENT_CHARACTER_UTF8 "\xEF\xBF\xBD"
#endif
#elif '^' == 95
#ifndef BOM_UTF8
# define BOM_UTF8 "\xDD\x73\x66\x73"
#endif
#ifndef REPLACEMENT_CHARACTER_UTF8
# define REPLACEMENT_CHARACTER_UTF8 "\xDD\x73\x73\x71"
#endif
#elif '^' == 176
#ifndef BOM_UTF8
# define BOM_UTF8 "\xDD\x72\x65\x72"
#endif
#ifndef REPLACEMENT_CHARACTER_UTF8
# define REPLACEMENT_CHARACTER_UTF8 "\xDD\x72\x72\x70"
#endif
#else
# error Unknown character set
#endif
lib/PerlIO/bom.pm view on Meta::CPAN
$PerlIO::bom::VERSION = '0.001';
use strict;
use warnings;
use XSLoader;
XSLoader::load(__PACKAGE__, __PACKAGE__->VERSION);
1;
#ABSTRACT: Automatic BOM handling in Unicode IO
__END__
=pod
=encoding UTF-8
=head1 NAME
PerlIO::bom - Automatic BOM handling in Unicode IO
=head1 VERSION
version 0.001
=head1 SYNOPSIS
open my $fh, '<:bom(utf-8)', $filename;
=head1 DESCRIPTION
This module will automate BOM handling. On a reading handle, it will try to detect a BOM and push an appropriate decoding layer for that encoding. If no BOM is detected the specified encoding is used, or UTF-8 if none is given.
A writing handle will be opened with the specified encoding, and a BOM will be written to it.
=head1 SYNTAX
This modules does not have to be loaded explicitly, it will be loaded automatically by using it in an open mode. The module has the following general syntax: C<:bom(encoding)> or C<:bom>. The encoding may be anything C<:encoding> accepts.
=head1 AUTHOR
Leon Timmermans <leont@cpan.org>
=head1 COPYRIGHT AND LICENSE
#! /usr/bin/perl
use strict;
use warnings FATAL => 'all';
use utf8;
use Test::More 0.89;
use Encode qw/encode decode/;
my $BOM = "\x{FEFF}";
my $text = "Hèló Wörld";
my %bom_for = (
'8' => "\xEF\xBB\xBF",
'16BE' => "\xFE\xFF",
'16LE' => "\xFF\xFE",
'32BE' => "\x00\x00\xFE\xFF",
'32LE' => "\xFF\xFE\x00\x00",
);
my @keys = sort { substr($a, 0, 2) <=> substr($b, 0, 2) || $a cmp $b } keys %bom_for;
for my $shortname (@keys) {
my $encoding = "UTF-$shortname";
subtest $encoding, sub {
{
my $encoded = encode($encoding, $BOM . $text);
open my $fh, '<:bom', \$encoded or die "Couldn't open $encoding: $!";
my $read = <$fh>;
is($read, $text, "Input is correct with BOM");
}
{
my $encoded = encode($encoding, $text);
open my $fh, "<:bom($encoding)", \$encoded or die "Couldn't open for $encoding: $!";
my $read = <$fh>;
is($read, $text, "Input is correct with default");
}
{
( run in 0.495 second using v1.01-cache-2.11-cpan-e9daa2b36ef )