dthtvk3666 2017-03-31 10:55
浏览 36
已采纳

如何在CodeIgniter中使用unicode?

I am using CI framework for my project. If I use like this

$title= "प्रदेश";      // प्रदेश is written in nepali langauge.

echo $title;        // It will display प्रदेश

Now I want to use

<a href = "<?php echo base_url("home/$title")?>">    //home is a controller  

Now In home controller if I tried to display$title it will not show प्रदेश.

It will display like this %E0%A4%AA%E0%A5%8D%E0%A4%B0%E0%A4%A6%E0%A5%87%E0%A4%B6

Please help me.

  • 写回答

1条回答 默认 最新

  • duanbi3151 2017-03-31 11:00
    关注

    The base_url calls urlencode on the string, which makes it into url entities.
    A space becomes %20 and things like that.

    The url that is displayed is actually correct and should be interpretted correctly by the server, even if it's gibberish according to humans.

    If you really want the human readable characters for some reason you can do two approaches, urldecode the resulting url(not recommended):

    echo urldecode(base_url("home/$title"));
    

    or

    echo base_url("home/").$title
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?