summaryrefslogtreecommitdiff
path: root/localmarkdown2sms
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2010-09-26 18:59:53 +0200
committerJonas Smedegaard <dr@jones.dk>2010-09-26 18:59:53 +0200
commit8f6bf384c28276b6f05f9679e9a4e690bdc79803 (patch)
treedc90b2154befc35c65421ff06bab32872e5ebbd4 /localmarkdown2sms
parent6ff2caadc23016b1ad8b2a669916fed6a5329e36 (diff)
Fix UTF-8 IO handling.
Diffstat (limited to 'localmarkdown2sms')
-rwxr-xr-xlocalmarkdown2sms11
1 files changed, 6 insertions, 5 deletions
diff --git a/localmarkdown2sms b/localmarkdown2sms
index 7d03df2..86b0f6d 100755
--- a/localmarkdown2sms
+++ b/localmarkdown2sms
@@ -22,6 +22,7 @@
use strict;
use warnings;
+use utf8; # this document itself is UTF-8 encoded.
use Env qw[$debug $info $warn $dummy $nosleep $urldecode];
use Log::Log4perl qw(:easy);
@@ -68,8 +69,8 @@ if ($urldecode) {
@ARGV = uri_unescape(@ARGV);
}
my ($phone) = shift @ARGV;
-my $inputstring = join(' ', @ARGV);
-my ($key) = lc (shift @ARGV);
+my $inputstring = decode('UTF-8', join(' ', @ARGV));
+my ($key) = lc(decode('UTF-8', shift @ARGV));
# strip international prefix
# (prefix is optional some places and illegal at other places - forgot where)
@@ -107,8 +108,8 @@ foreach my $file (read_dir( $path )) {
my ($warn_nonkey_delay, $warn_nonkey_content);
next unless ($file =~ /\.mdwn$/);
foreach my $line (read_file( File::Spec->catfile($path, $file))) {
+ $line = &transliterate(decode('UTF-8', $line));
chomp $line;
- $line = &transliterate($line);
my $content;
# headline
if ($line =~ /^(#+)\s*(.*?)\s*$/) {
@@ -207,11 +208,11 @@ sub tidymsg {
sub transliterate {
my $string = shift @_;
- my $res = encode('UTF-8', decode('GSM0338', encode('GSM0338', $string, sub {
+ my $res = decode('GSM0338', encode('GSM0338', $string, sub {
my $ascii = unidecode(chr $_[0]);
_utf8_off($ascii);
$ascii;
- })));
+ }));
return $res || "";
}