简体   繁体   中英

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. I assume a misconfiguration of the server, since the files are all saved in UTF-8 and contain

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

In the -Tag of the files.

Anyone an idea how to get rid of those ? I thought already of the httpd.conf , but there is already something like

#UTF 8
AddDefaultCharset utf-8

in it. The php.ini also includes

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. 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). 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!

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 ).
However, if you are saving the file in a different encoding that UTF-8, then it is displayed in the wrong way.

My suggestion is to check with your editor which encoding it is using, and tell it to use UTF-8 by default.

I run into the same problem after updating 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:

Changing the default-charset into "windows-1252" did the trick for me.

  1. Open "my.ini" in "C:\\xampp\\mysql\\bin\\" directory.
  2. Remove comment tag '#' from following code

    \ninit-connect=\\'SET NAMES utf8\\' \ncollation_server=utf8_unicode_ci \ncharacter_set_server=utf8 \nskip-character-set-client-handshake\ncharacter_sets-dir="C:/xampp/mysql/share/charsets" \n

It's Work for me

The PHP file was in ANSI format. I changed it to UTF-8 and everything started working. I did not change any code.

I add to my.ini config file xampp and resolve

[mysqld] 

character-set-server = utf8

delete this line in file mysql/bin/my.ini

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

or change utf8mb4 to uft8

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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