简体   繁体   English

Apache (XAMPP) 服务器的字符集

[英]Charset of Apache (XAMPP) Server

I run a XAMPP Apache PHP Server on my Mac and I am facing the following problem: German special characters like ä ö ü and ß are displayed with strange questiontags instead of the correct symbol.我在 Mac 上运行 XAMPP Apache PHP 服务器,但面临以下问题:德语特殊字符,如 ä ö ü 和 ß 显示时带有奇怪的问题标签,而不是正确的符号。 I assume a misconfiguration of the server, since the files are all saved in UTF-8 and contain我假设服务器配置错误,因为文件都保存在 UTF-8 中并包含

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

In the -Tag of the files.在文件的 -Tag 中。

Anyone an idea how to get rid of those ?任何人都知道如何摆脱那些 ? I thought already of the httpd.conf , but there is already something like我已经想到了 httpd.conf ,但已经有类似的东西

#UTF 8
AddDefaultCharset utf-8

in it.在里面。 The php.ini also includes php.ini 还包括

default_charset = "utf-8“

I really dont know how to proceed and my whole page looks not as nice as it should with those strange question tags...我真的不知道如何继续,我的整个页面看起来不像那些奇怪的问题标签那样好......

Thanks for your Help!感谢您的帮助! Tim蒂姆

I was having the same problem on my XAMPP local server and none of those things worked for me.我在我的 XAMPP 本地服务器上遇到了同样的问题,但这些东西都不适合我。 The problem was in the transfer of data between mySQL (where all my foreign language looked good) and the server (where everything seemed good too).问题出在 mySQL(我所有的外语都很好)和服务器(一切都很好)之间的数据传输。 I was just missing this one statement in my.ini "character_set_server=utf8" which seems to affect data communication beetween server and mySQL DON't change any other UTF-8 statements at the same time!我只是在 my.ini "character_set_server=utf8" 中遗​​漏了这一条语句,它似乎影响了服务器和 mySQL 之间的数据通信 不要同时更改任何其他 UTF-8 语句!

Did you type these characters inside the source file?您是否在源文件中键入了这些字符? In this case, which encoding was the source file saved in?在这种情况下,源文件保存在哪种编码中?

With that meta tag "Content-Type" you are telling the browser to interpret the page as UTF-8 ( despite whatever other value the server is returning ).使用元标记“Content-Type”,您告诉浏览器将页面解释为 UTF-8(不管服务器返回什么其他值)。
However, if you are saving the file in a different encoding that UTF-8, then it is displayed in the wrong way.但是,如果您以与 UTF-8 不同的编码保存文件,则会以错误的方式显示。

My suggestion is to check with your editor which encoding it is using, and tell it to use UTF-8 by default.我的建议是与您的编辑器核对它使用的是哪种编码,并告诉它默认使用 UTF-8。

I run into the same problem after updating XAMPP.更新 XAMPP 后我遇到了同样的问题。 I am using an other charset to display all kinds of characters used in countries like Holland, Germany, Norway, Sweden en Denmark.我正在使用其他字符集来显示荷兰、德国、挪威、瑞典和丹麦等国家/地区使用的各种字符。 So my HTML contains:所以我的 HTML 包含:

Changing the default-charset into "windows-1252" did the trick for me.将默认字符集更改为“windows-1252”对我来说很有效。

  1. Open "my.ini" in "C:\\xampp\\mysql\\bin\\" directory.打开“C:\\xampp\\mysql\\bin\\”目录下的“my.ini”。
  2. Remove comment tag '#' from following code从以下代码中删除注释标签“#”

    \ninit-connect=\\'SET NAMES utf8\\' init-connect=\\'SET NAMES utf8\\'\ncollation_server=utf8_unicode_ci collat​​ion_server=utf8_unicode_ci\ncharacter_set_server=utf8 character_set_server=utf8\nskip-character-set-client-handshake跳过字符集客户端握手\ncharacter_sets-dir="C:/xampp/mysql/share/charsets" character_sets-dir="C:/xampp/mysql/share/charsets"\n

It's Work for me这对我有用

The PHP file was in ANSI format. PHP 文件采用 ANSI 格式。 I changed it to UTF-8 and everything started working.我将其更改为 UTF-8,一切都开始工作了。 I did not change any code.我没有更改任何代码。

I add to my.ini config file xampp and resolve我添加到 my.ini 配置文件 xampp 并解决

[mysqld] 

character-set-server = utf8

delete this line in file mysql/bin/my.ini删除文件 mysql/bin/my.ini 中的这一行

character-set-server=utf8mb4
collation-server=utf8mb4_general_ci

or change utf8mb4 to uft8或将 utf8mb4 更改为 uft8

character-set-server=utf8
collation-server=utf8_general_ci

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

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