西班牙语字符在javascript中无法正常显示? [英] spanish characters not coming properly in javascript?

查看:109
本文介绍了西班牙语字符在javascript中无法正常显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下正则表达式.在jsfiddle中此处.

Hi I am using the following regular expression.It works fine in jsfiddle here.

                     var string="zñáéíóúü1111";

                       if(/^[0-9a-zñáéíóúü]+$/i.test(string))
                {
                    $("#result").text("oK WITH THE INPUT");

                }
                else
                {
                        $("#result").text("error");

                }

但是,当我将代码放入浏览器中时,西班牙语字符不会正确出现(一些奇怪的字符)(在浏览器中查看源代码).并且上述正则表达式无法正常工作.

But when I put the code in browser the spanish characters not coming proprely(Some strange characters) (view source code in browser). and the above regular expression not working properly.

但是我有

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

在浏览器中.

当我从用户那里获得输入时,我不确定它为什么不能在我的页面上工作的原因.但是我发出警报并检查了该字符串中的字符.两者相同.

I am not sure about the reason why its not working on my page , when I am getting the input from the user.But I put alert and checked the characters in this string .Both are same.

推荐答案

我猜想您的HTML或JS文件或两者都不保存为UTF-8.您应该调整编辑器的字符集设置.根据不同的编辑器,您可能会在保存对话框或文件属性中找到它们.

I guess your HTML or JS file or both of them are not saved as UTF-8. You should adjust your editor's charset settings. Depending on the editor you might find them in the save dialog or the files' properties.

这篇关于西班牙语字符在javascript中无法正常显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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