将特殊字符(即Umlaut)转换为最可能的ascii表示形式 [英] Convert special character (i.e. Umlaut) to most likely representation in ascii

查看:71
本文介绍了将特殊字符(即Umlaut)转换为最可能的ascii表示形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法或转换表,它知道如何将Umlauts和特殊字符转换为它们最可能的ascii表示形式.

i am looking for a method or maybe a conversion table that knows how to convert Umlauts and special characters to their most likely representation in ascii.

示例:

Ärger = aerger
Bôhme = bohme
Søren = soeren
pjérà = pjera

有人知道吗?

更新: 除了公认的答案,我还发现PECL Normalizer 是很有意思,尽管由于服务器没有它并且没有为我更改,所以我无法使用它.

Update: Apart from the good accepted Answer, i also found PECLs Normalizer to be quite interesting, though i can not use it due to the server not having it and not being changed for me.

也请查看此问题这里的答案对您的帮助不足.

Also do check out this Question if the Answers here do not help you enough.

推荐答案

我发现iconv完全不可靠,并且我不喜欢preg_match解决方案和大数组...所以我最喜欢的方式是...

I find iconv completely unreliable, and I dislike preg_match solutions and big arrays ... so my favorite way is ...

    function toASCII( $str )
    {
        return strtr(utf8_decode($str), 
            utf8_decode('ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ'),
            'SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy');
    }

这篇关于将特殊字符(即Umlaut)转换为最可能的ascii表示形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆