[LON-CAPA-cvs] cvs: loncom /localize transliterate.pm
raeburn
raeburn at source.lon-capa.org
Sat Mar 2 18:08:51 EST 2019
raeburn Sat Mar 2 23:08:51 2019 EDT
Modified files:
/loncom/localize transliterate.pm
Log:
- Bug 6792
Normalize unicode representations before transliteration.
Index: loncom/localize/transliterate.pm
diff -u loncom/localize/transliterate.pm:1.1 loncom/localize/transliterate.pm:1.2
--- loncom/localize/transliterate.pm:1.1 Tue Feb 26 14:42:22 2019
+++ loncom/localize/transliterate.pm Sat Mar 2 23:08:51 2019
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Transliteration to ascii
#
-# $Id: transliterate.pm,v 1.1 2019/02/26 14:42:22 raeburn Exp $
+# $Id: transliterate.pm,v 1.2 2019/03/02 23:08:51 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -60,6 +60,7 @@
use utf8;
use Text::Unidecode qw(unidecode);
use Encode qw(decode_utf8 encode_utf8);
+use Unicode::Normalize qw(normalize);
=pod
@@ -90,12 +91,14 @@
sub fname_to_ascii {
my ($fname,$language) = @_;
if ($fname =~ /([^\x{00}-\x{7f}])/) {
- $fname=&decode_utf8($fname);
+ $fname = decode_utf8($fname);
+ $fname = normalize('D',$fname);
+ $fname = normalize('C',$fname);
if ($language eq 'de') {
$fname = &german_to_ascii($fname);
}
$fname = unidecode($fname);
- $fname=&encode_utf8($fname);
+ $fname = encode_utf8($fname);
}
return $fname;
}
More information about the LON-CAPA-cvs
mailing list