dounie5475 2014-01-17 10:15
浏览 32
已采纳

用PHP标准化土耳其语?

Is there a way to simply normalize turkish characters like Ç, Ğ, İ, Ö, Ş, Ü and ı ?

cause now I'm using str_replace but that doesn't seem the right way to go, cause it's possible to forget a character.... Is there a more standard way? I tried to use the normalize method within the PHP internationalization module, but the Turkish characters stay Turkish. I would like to replace them with normal characters for the URL. So Ç becomes C and Ş becomes S, and so on.

  • 写回答

1条回答 默认 最新

  • dtgj8529 2014-01-17 10:20
    关注

    What do you mean by normalization? Just take the characters as they come in, but put your scripts, connection and html in correct encoding.

    UTF-8 suggested, explanation: UTF-8 vs. Unicode

    If you only want ASCII chars, you can test this by something like ord($char) < 255.

    For conversion look into these functions:

    http://php.net/iconv

    http://php.net/utf8_encode

    http://php.net/mb_convert_encoding

    A call similiar to

    $str = iconv('UTF-8', 'ASCII//TRANSLIT', $str);
    

    would do the trick.

    Another preg_replace way: Convert special characters to normal characters using PHP, like ã, é, ç to a, e, c

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog