summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2010-09-26 02:03:35 +0200
committerJonas Smedegaard <dr@jones.dk>2010-09-26 02:03:35 +0200
commit6ff2caadc23016b1ad8b2a669916fed6a5329e36 (patch)
tree06b797b42d0126d80a53a3e96d9e72980d81b7a2
parent0d252999c71b69b756acf5346536dab44f461066 (diff)
Fix avoid decoding UTF-8; capture output of transliteration; fallback to empty string (not null).
-rwxr-xr-xlocalkannel-dispatch2
-rwxr-xr-xlocalmarkdown2sms6
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 {