Convert-Braille
view release on metacpan or search on metacpan
examples/demo.pl view on Meta::CPAN
# $Convert::Braille::dot_separator ="-";
if ( $] > 5.007 ) {
binmode(STDOUT, ":utf8");
}
my $ascii = "HELLO";
print "[0/6] Testing Braille-ASCII : \"$ascii\"\n";
my $unicode = brailleAscii_To_Unicode ( $ascii );
print "[1/6] brailleAscii_To_Unicode : $ascii => $unicode (has length: ", length($unicode), ")\n";
my $dots = brailleAscii_To_DotNumbers ( $ascii );
print "[2/6] brailleAscii_To_DotNumbers : $ascii => $dots\n";
$ascii = brailleDotNumbers_To_Ascii ( $dots );
print "[3/6] brailleDotNumbers_To_Ascii : $dots => $ascii\n";
$unicode = brailleDotNumbers_To_Unicode ( $dots );
print "[4/6] brailleDotNumbers_To_Unicode: $dots => $unicode (has length: ", length($unicode), ")\n";
$Convert::Braille::dot_separator ="-";
$dots = brailleUnicode_To_DotNumbers ( $unicode );
print "[5/6] brailleUnicode_To_DotNumbers: $unicode => $dots\n";
$Convert::Braille::dot_separator = undef;
$ascii = brailleUnicode_To_Ascii ( $unicode );
print "[6/6] brailleUnicode_To_Ascii : $unicode => $ascii\n";
__END__
=head1 NAME
demo.pl - Unicode, ASCII, DotNumbers, Conversion Demonstration of Braille.
=head1 SYNOPSIS
examples/english.pl view on Meta::CPAN
my $ascii = "HELLO";
print "[0/6] Testing Braille-English : \"$ascii\"\n";
my $english = brailleAscii_To_English ( $ascii );
print "[1/6] brailleAscii_To_English : $ascii => $english (has length: ", length($english), ")\n";
$ascii = english_To_BrailleAscii ( $english );
print "[2/6] english_To_BrailleAscii : $english => $ascii\n";
my $unicode = english_To_BrailleUnicode ( $english );
print "[3/6] english_To_BrailleUnicode : $english => $unicode (has length: ", length($unicode), ")\n";
$english = brailleUnicode_To_English ( $unicode );
print "[4/6] brailleUnicode_To_Englih : $unicode => $english\n";
$Convert::Braille::dot_separator ="-";
my $dots = english_To_BrailleDotNumbers ( $english );
print "[5/6] english_To_BrailleDotNumbers: $english => $dots\n";
$english = brailleDotNumbers_To_English ( $dots );
print "[6/6] brailleDotNumbers_To_English: $dots => $english\n";
$Convert::Braille::dot_separator = undef;
examples/ethiopic.pl view on Meta::CPAN
if ( $] > 5.007 ) {
binmode(STDOUT, ":utf8");
}
my $ethio = "á°ááá³";
my $ascii = "S5LAMTA";
print "[0/6] Testing Braille-Ethiopic : \"$ascii\" & \"$ethio\"\n";
my $unicode = brailleAscii_To_Ethiopic ( $ascii );
print "[1/6] brailleAscii_To_Ethiopic : $ascii => $unicode (has length: ", length($unicode), ")\n";
my $asciiOut = ethiopic_To_BrailleAscii ( $ethio );
print "[2/6] ethiopic_To_BrailleAscii : $ethio => $asciiOut\n";
my $braille = ethiopic_To_BrailleUnicode ( $ethio );
print "[3/6] ethiopic_To_BrailleUnicode : $ethio => $braille (has length: ", length($braille), ")\n";
$ethioOut = brailleUnicode_To_Ethiopic ( $braille );
print "[4/6] brailleUnicode_To_Ethiopic : $braille => $ethioOut\n";
lib/Convert/Braille.pm view on Meta::CPAN
$ascii =~ s/(.)/_convert ( $1, \%BrailleAscii_To_Unicode )/ge;
$ascii;
}
sub brailleUnicode_To_Ascii
{
return unless ( defined($_[0]) );
my $unicode = $_[0];
#
# first strip off dots 7 and 8:
#
if ( $unicode =~ /â¡-⣿/ ) {
$unicode =~ tr/â¢-⣿/â -â¡¿/; # fold upper half
$unicode =~ tr/â¡-â¡¿/â -â ¿/; # fold upper quarter
}
$unicode =~ s/(.)/_convert ( $1, \%BrailleUnicode_To_Ascii )/ge;
$unicode;
}
sub brailleUnicode_To_DotNumbers
{
my $string = shift; # no || "" because fail for '0'
return "" if !defined $string || $string eq "";
my $braced = ( @_ ) ? shift : 0 ;
( run in 0.486 second using v1.01-cache-2.11-cpan-88abd93f124 )