tools: validate utf8 encoding in stdin/out
[sheet.git] / tools / mkwordlist
index 78859b4a09cb2a0cb48dd39c5f7a1edddd90a5ca..78e36b6adb5d652e258ec1ad10a9df255d6da9e9 100755 (executable)
@@ -4,7 +4,7 @@ use warnings;
 
 BEGIN { push @INC, '.' }
 use Shiar_Sheet::DB;
-use open ':std' => ':utf8';
+use open ':std' => ':encoding(utf-8)';
 my $db = Shiar_Sheet::DB->connect;
 
 say 'use utf8;';
@@ -13,7 +13,7 @@ use Data::Dump 'pp';
 my %rows;
 if (my $lang = shift @ARGV) {
        my %filter = (lang => $lang);
-       my $cols = "ref, id, prio, array_to_string(form || alt, '/')";
+       my $cols = "ref, array_to_string(form || alt, '/'), prio + coalesce(grade, 90) / 100::float, id, cat";
        %rows = $db->select(_word_ref => $cols, \%filter)->map_arrays;
        say pp \%rows
                =~ s/\\x\{([0-9A-F]+)\}/chr hex $1/ger;