重音字符未被正确检索 [英] Accented chars are not retrieved correctly

查看:77
本文介绍了重音字符未被正确检索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天我遇到了这个奇怪的问题。我们在我们的页面中有一个电子邮件字段,如果用户输入:

specialcharacter123@eñe.es



然后,只有在Chrome浏览器的情况下 b
$ b 我试过: b

  jQuery('#email')。val()



  document.getElementById('email')。value 

两者都给了我相同的结果。 (它在Safari中工作正常)。



另外,我已经在页面中显示了这一点:

 < meta charset =utf-8/> 
< meta http-equiv =Content-Typecontent =text / html; charset = utf-8/>

我无法弄清楚这里有什么不对。

域名只能包含ASCII字符,请参阅国际化域名。该URL在做请求时可以很好地工作,但如果要将其显示为UTF8,则需要将其转换。有各种语言的解决方案,对于JavaScript,您可以使用


I encountered this strange issue today. We have an email field in our page, and if a user enters:
specialcharacter123@eñe.es

Then only in case of Chrome I am getting specialcharacter123@xn--ee-zja.es :

I tried:

jQuery('#email').val()  

And

document.getElementById('email').value    

Both gave me same results. ( It is working fine in Safari ).

Also I already have this in the page:

<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  

I am unable to get any clue what's wrong here.

解决方案

Domain names can include ASCII characters only, see Internationalized domain name. The URL will work just fine when doing requests, but if you want to display it as UTF8, you need to convert it. There are various solutions for various languages, for JavaScript you could use punycode.js.

这篇关于重音字符未被正确检索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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