How to convert letters with accents, umlauts, etc to their ASCII counterparts in Perl?

后端 未结 4 979
清歌不尽
清歌不尽 2020-12-01 17:07

I\'m writing a program that works with documents in Perl and a lot of the documents have characters such as ä, ö, ü, é, etc (both capital and lowercase). I\'d l

4条回答
  •  庸人自扰
    2020-12-01 17:21

    As usual, if you think of a problem which most certainly is not yours only, there's already a solution on CPAN. ) In this case it's called Text::Unidecode

    use warnings;
    use strict;
    use utf8;
    use Text::Unidecode;
    print unidecode('ä, ö, ü, é'); # will print 'a, o, u, e'
    

提交回复
热议问题