From 6ff2caadc23016b1ad8b2a669916fed6a5329e36 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Sun, 26 Sep 2010 02:03:35 +0200 Subject: Fix avoid decoding UTF-8; capture output of transliteration; fallback to empty string (not null). --- localkannel-dispatch | 2 +- localmarkdown2sms | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/localkannel-dispatch b/localkannel-dispatch index a142762..5f96b36 100755 --- a/localkannel-dispatch +++ b/localkannel-dispatch @@ -27,7 +27,7 @@ lctransliterate() { echo "$1" | perl -n \ -e 'use Text::Unidecode;' \ -e 'use Encode 2.12 qw(encode decode _utf8_off);' \ - -e 'print lc(encode("UTF-8", decode("GSM0338", encode("GSM0338", decode("UTF-8", $_),' \ + -e 'print lc(encode("UTF-8", decode("GSM0338", encode("GSM0338", $_,' \ -e 'sub {$a=unidecode(chr $_[0]); _utf8_off($a); $a;}' \ -e '))));' diff --git a/localmarkdown2sms b/localmarkdown2sms index d86cd1c..7d03df2 100755 --- a/localmarkdown2sms +++ b/localmarkdown2sms @@ -108,7 +108,7 @@ foreach my $file (read_dir( $path )) { next unless ($file =~ /\.mdwn$/); foreach my $line (read_file( File::Spec->catfile($path, $file))) { chomp $line; - &transliterate($line); + $line = &transliterate($line); my $content; # headline if ($line =~ /^(#+)\s*(.*?)\s*$/) { @@ -207,13 +207,13 @@ sub tidymsg { sub transliterate { my $string = shift @_; - my $res = encode('UTF-8', decode('GSM0338', encode('GSM0338', decode('UTF-8', $string), sub { + my $res = encode('UTF-8', decode('GSM0338', encode('GSM0338', $string, sub { my $ascii = unidecode(chr $_[0]); _utf8_off($ascii); $ascii; }))); - return $res; + return $res || ""; } sub sendmsg { -- cgit v1.2.3