App-Brl2Brl
view release on metacpan or search on metacpan
share/en-us-brf.dis
share/es-new.dis
share/es-old.dis
share/hu-backtranslate-correction.dis
share/nl-BE.dis
share/no-no-braillo-047-01.dis
share/no-no-generic.dis
share/no-no.dis
share/ru-brf.dis
share/ru-letters.dis
share/ru-unicode.dis
share/se-se.dis
share/text_nabcc.dis
share/uni-text.dis
share/unicode-without-blank.dis
share/unicode.dis
share/us-table.dis
share/wordcx.dis
META.yml Module YAML meta-data (added by MakeMaker)
META.json Module JSON meta-data (added by MakeMaker)
lib/App/Brl2Brl.pm view on Meta::CPAN
=head1 SYNOPSIS
This module is useful if you have a text coded for one braille character set and need to convert it to another, e.g. you have a text in North American ASCII or Eurobraille and you need it in Unicode braille.
use App::Brl2Brl;
my $brl_obj = App::Brl2Brl->new({ # to read in the specified files and store the characters/dots in hashes
from_table_file => 'en-us-brf.dis', # or another display table
to_table_file => 'unicode.dis', # or another display table
warn => 1, # if you want to be warned if a char isn't defined in table
});
my $out = $brl_obj->switch_brl_char_map('ABC123'); # switch from BRF to Unicode braille
print "$out\n";
Or you may do:
use App::Brl2Brl;
my $from_table_file = 'en-us-brf.dis';
my $to_table_file = 'unicode.dis';
my %from_table = parse_dis( "$from_table_file" );
my %to_table = parse_dis( "$to_table_file" );
while( <> ){
my $out = Conv( \%from_table, \%to_table, $_);
print "$out\n";
};
=head1 EXPORT
lib/App/Brl2Brl.pm view on Meta::CPAN
Conv - Convert from one display table to another.
=head1 SUBROUTINES/METHODS
=head2 new
Takes the following parameters:
path => '/usr/share/liblouis/tables', # path to liblouis tables
from_table_file => 'en-us-brf.dis', # or another display table
to_table_file => 'unicode.dis', # or another display table
warn => 1, # if you want to be warned if a char isn't defined in table
The path is optional. App::Brl2Brl comes with a copy of the data files
and knows where to find them. Only provide this if you want to use a
different set of data files, perhaps a more recent one. As with most
liblouis software you can also set C<LOUIS_TABLEPATH> in your environment.
The order of precedence is that the value in a C<path> argument will be used,
falling back to C<LOUIS_TABLEPATH>, falling back to using the data bundled with
the module.
lib/App/Brl2Brl.pm view on Meta::CPAN
}
close( DIS );
my( $chr, $dts );
while( ($chr, $dts) = each (%table) ){
$dts = $table{$chr};
next unless( $dts == 1 );
last;
} # while
if( $chr =~ /â / ){ # if dot 1 is x2801
$table{"â "} = 0; # inject unicode brl space
} else {
$table{" "} = "0";
} # if
return( %table );
} # parse_dis
=head2 Conv
Converts a string, character by character, from %from_table to %to_table.
share/ru-unicode.dis view on Meta::CPAN
# This table maps the Cyrillic dot patterns that are defined in
# ru-chardefs.cti with a virtual dot 9 to Unicode braille. The dot 9
# is simply dropped.
# Note that ru-letters.dis maps Latin to lowercase letters and
# Cyrillic to uppercase letters. But in Unicode this distinction can
# not be made because the Latin and Cyrillic alphabet are translated
# to the same dot patterns.
include unicode.dis
display \x2841 179
display \x2843 1279
display \x2849 1479
display \x2859 14579
display \x2851 1579
display \x284B 12479
display \x285B 124579
display \x2853 12579
display \x284A 2479
share/unicode-without-blank.dis view on Meta::CPAN
# liblouis is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with liblouis. If not, see
# <http://www.gnu.org/licenses/>.
display \s 0
include unicode.dis
display \x2800 0
t/Brl2Brl.t view on Meta::CPAN
use strict;
use warnings;
use utf8;
use Test::More;
use Test::Exception;
use App::Brl2Brl;
my $brl_obj = App::Brl2Brl->new( {
from_table_file => "unicode.dis",
to_table_file => "en-us-brf.dis",
warn => 1,
} ) or die "Couldn't initialize the braille object.";
ok( defined $brl_obj, ' The new() returned something' );
ok( $brl_obj->isa( 'App::Brl2Brl' ), " It's class is App::Brl2Brl" );
my $in = "â â â â ";
my $out = $brl_obj->switch_brl_char_map( $in );
ok( $out =~ /ABC1/, ' The switch_brl_char_map works.' );
# now test that LOUIS_TABLEPATH works. We set a bogus path
# in it so expect an exception containing the bogus path.
$ENV{LOUIS_TABLEPATH} = '/i/like/eating/weevils';
throws_ok
{
my $brl_obj = App::Brl2Brl->new( {
from_table_file => "unicode.dis",
to_table_file => "en-us-brf.dis",
warn => 1,
} )
}
qr{Error opening file /i/like/eating/weevils/unicode.dis},
"pays attention to LOUIS_TABLEPATH";
# leave the env var still set, but pass in a path argument. The
# argument should take precedence.
throws_ok
{
my $brl_obj = App::Brl2Brl->new( {
path => '/i/like/eating/slugs',
from_table_file => "unicode.dis",
to_table_file => "en-us-brf.dis",
warn => 1,
} )
}
qr{Error opening file /i/like/eating/slugs/unicode.dis},
"pays attention to a 'path' argument";
done_testing;
( run in 0.619 second using v1.01-cache-2.11-cpan-88abd93f124 )