Page 2 of 2

Re: Unicode Greek friendly Unix tools

Posted: March 21st, 2016, 6:04 pm
by caseyperkins
Jonathan Robie wrote:
caseyperkins wrote:I would say stick with Perl. This kind of thing is where Perl really excels. I was able to work with Perl for processing Unicode Greek texts with much greater ease than would have been possible with other programming languages.
Compared to Python or Ruby? What advantages do you see?

My impression is that these languages are broadly similar in what they can do.
It may be that I am outdated in my conceptions of Python and Ruby's current capabilities in this regard. (I use Python nearly every day, but not for this purpose). When I researched this for a project a few years ago, both - especially Ruby - were behind Perl in Unicode processing capabilities, and Perl did everything I needed it to do, with aplomb.

Re: Unicode Greek friendly Unix tools

Posted: March 31st, 2016, 12:02 am
by Stephen Carlson
I discovered that the Unicode::Collate module in Perl does the right thing.

I'm sure I'm not the prettiest coder, but here's something that sorts lines with Unicoded Greek text:

Code: Select all

#!/usr/bin/perl -la
BEGIN {
    use utf8;
    use Encode;
    use Unicode::Collate;
    $Collator = Unicode::Collate->new();
}
push @x, decode_utf8($_);
END {
    map { print encode_utf8($_) } $Collator->sort(@x);
}