在Chrome中输入带有重音字符的电子邮件值错误 [英] Input type email value in Chrome with accented characters wrong

查看:115
本文介绍了在Chrome中输入带有重音字符的电子邮件值错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Chrome中输入重音字符到输入类型的电子邮件时,它会将值更改为奇怪的值。



输入电子邮件时:test@Bücher.ch输入值变为: test@xn--bcher-kva.ch

  $('#email')。val()//  - > test@xn--bcher-kva.ch 
document.getElementById('email')。value // - > test@xn--bcher-kva.ch

输入类型文本不会发生这种情况,或者在其他主流浏览器中。



查看此小提琴例如。这是怎么回事,我该如何解决它? 解决方案

我认为这不是错误,这是因为规范。 Chrome只是按照不同于其他浏览器的方式遵循规范:)并将IDN翻译为其ascii表示形式。

https://code.google.com/p/chromium/issues/detail?id=410937



要解码它,您可以使用一些第三方解决方案,比如

将punycode与破折号字符转换为Unicode


When entering accented characters into an input type email in Chrome, it changes the value to something strange.

When entering the email: test@Bücher.ch the input value becomes: test@xn--bcher-kva.ch.

$('#email').val() // --> test@xn--bcher-kva.ch
document.getElementById('email').value // --> test@xn--bcher-kva.ch

This does not happen with an input type text, or in other major browsers.

See this fiddle for example. What is going on here and how do I get around it?

解决方案

I think it's not an error, it's because of the specification. Chrome just follows the specification in a different way than other browsers:) and translate the IDN into its ascii representation.

https://code.google.com/p/chromium/issues/detail?id=410937

To decode it back you can use some 3rd party solution such as

Converting punycode with dash character to Unicode

这篇关于在Chrome中输入带有重音字符的电子邮件值错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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