简体   繁体   English

javascript文件和简单的php文件中的字符编码

[英]Character encoding in javascript file and a simple php file

I got problem with some special characters. 我遇到一些特殊字符的问题。 I have defined the meta tag as 我已经将meta标签定义为

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

so far so good. 到现在为止还挺好。 But in one occassion I have a select tag with many options with many special characters. 但是在某些情况下,我会有一个选择标签,其中包含许多带有许多特殊字符的选项。 I got problem showing (å ä ö). 我在显示(åäö)时遇到问题。 They are defined in .js file and are appended to the document using DOM. 它们在.js文件中定义,并使用DOM附加到文档中。 Pls. are there any solution except using &... forgot the name for that type. 除了使用&...以外,还有什么解决方案吗?忘记了该类型的名称。

Second character problem I have is in php. 我遇到的第二个字符问题是在php中。 I try to send an email with Amazon SES. 我尝试通过Amazon SES发送电子邮件。

<?php

$message['Body.Html.Data'] = "Please Confirm that you are a Tönt by clicking on this link"." ....<a href='s'>Tönt</a>";
$message['Body.Html.Charset'] = 'utf-8';

?>

the ö is not showing properly? ö显示不正确?

You'd better use: 您最好使用:

<?php header('Content-type: text/html; charset=utf-8'); ?>

At the very top of your PHP file, no need to use http-equiv metas when you can send some real http headers ;-) 在PHP文件的顶部,当您可以发送一些实际的HTTP标头时,无需使用http-equiv metas ;-)

Also check if your files (both PHP and JS) are encoded in UTF8 in your editor. 还要检查您的文件(PHP和JS)是否在编辑器中以UTF8编码。 Setting an UTF8 header on non UTF8 files will produce strange results for sure! 在非UTF8文件上设置UTF8标头肯定会产生奇怪的结果!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM