友好网址中的西里尔字母问题 [英] Problem with cyrillic characters in friendly url

查看:120
本文介绍了友好网址中的西里尔字母问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是东西.我有友好的网址,例如

Here's the thing. I have friendly urls like

http://site.com/blog/read /мъдростта-на-вековете

http://site.com/blog/read/мъдростта-на-вековете

http://site.com/blog/read/green-apple

最后一段实际上是博客文章的友好标题.问题是,当我尝试将该段传递给数据库时,西里尔字母字体变成类似%D1%8A%D0%B4%D1%80%D0%BE%D1%81%D1%8 ,并且无法匹配数据库记录.在我的浏览器的地址栏中,它看起来很正常(мъдростта-на-вековете),但如果我选择复制网址位置",则最后一段会再次变成这些奇怪的字符.我正在使用 CodeIgniter ,并且所有内容都设置为UTF-8.

The last segment is actually the friendly title of the blog article. The problem is when I try to pass that segment to the database, the cyrillic fonts turn into something like %D1%8A%D0%B4%D1%80%D0%BE%D1%81%D1%8 and couldn't match the database record. In the address bar in my browser it looks normal (мъдростта-на-вековете) but if I choose 'copy url location' the last segment again turns into these strange characters. I'm using CodeIgniter and everything is set to UTF-8.

请帮助! :(

推荐答案

仅对文本进行编码以符合URL规范.

The text is just being encoded to fit the specification for URLs.

将数据回显到日志中,以查看您实际试图传递给数据库的内容.

Echo out the data to a log to see what you are actually trying to pass to the database.

您应该可以使用 urldecode 对其进行解码.

You should be able to decode it with urldecode.

这篇关于友好网址中的西里尔字母问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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