Apache ignores meta charset on HTML display in browser - php

I have problem with meta charset encoding. I have a Zend App which inserts the meta charset into phtml file this way:
$this->headMeta()->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8');
$this->headMeta();
In browser, the page has set the us-ascii charset. I don't know why it's happening.
Apache and PHP conf files have set charset with UTF-8 encoding.
My local server is set on Linux Mint (on VirtualBox in Windows 7). File encoding conversion doesn't change anything.
===============
The problem occured because of php5-tidy Apache module.

Take look here: How to set charset to UTF-8 in a Zend application? .Make sure your working files are saved with utf-8 encoding.

Related

WAMP (3.0.6) PHP (7.0.1) CLI issues with UTF-8

When I set my PATH to point to my XAMPP PHP (5.6, or 7.1) and then run php test.php containing
<?php
echo 'ěščřžýáíé';
encoded in UTF-8, then I get the ěščřžýáíé output displayed correctly in my CLI (Git Bash).
However, when I change my PATH to point to any WAMP PHP (5.6.25, or 7.0.10), as I wanted to part with XAMPP, I get broken output: ─Ť┼í─Ź┼Ö┼ż├Ż├í├ş├ę.
There is the default_charset = "UTF-8" line in all three of WAMP's php.ini files
I have added the line AddDefaultCharset UTF-8 to my WAMP's httpd.conf, though that shouldn't matter at all in CLI mode
I have tried comparing contents of the PHP configuration files (XAMPP/WAMP) side by side but couldn't find any relevant differences

Wordpress site showing special charactors in site

My customer has a WordPress site and last week we have migrated it to a cPanel server after that the site showing special characters like ! and ? in the website. Can somebody let me know how to remove this?
Server: Centos 6
cPanel: WHM 56.0
PHP : 5.6.23
MySQL : 5.6
It's UTF8 Encoding problem, sometimes it happens when you migrate wordpress site from one host to another, you should select correct character set while exporting database backup.
Open and edit your WordPress wp-config.php file. Then find the following two lines and if it is not like that then you should change them as shown below.
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', ');
If this doesn't work try googling "special character problem wordpress"
PHP 5.6 changes the default value of default_charset to UTF-8. Change that value to ISO-8859-1 in your php.ini file and restart apache. See if that fix the issue.
Or convert the encoding of php textfiles to utf8 and don't change defaults.

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!
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.
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.
Open "my.ini" in "C:\xampp\mysql\bin\" directory.
Remove comment tag '#' from following code
init-connect=\'SET NAMES utf8\'
collation_server=utf8_unicode_ci
character_set_server=utf8
skip-character-set-client-handshake
character_sets-dir="C:/xampp/mysql/share/charsets"
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

UTF-8 text is garbled when form is posted as multipart/form-data in PHP

I have a PHP script to publish articles. It was working perfectly fine until we added the file uploading support. To enable uploading of files, we had to change enctype of tag to multipart/form-data. Now, whenever we try to submit an article with multibyte characters, they become garbled after you receive them via $_POST. If we remove the form's enctype, then it works fine.
We have searched for all over the web for a php centric solution but without luck. There is an accept-charset attribute of tag but it does not work in IE. There is a solution for JSP at UTF-8 text is garbled when form is posted as multipart/form-data but no solution for PHP. So, please help!
if you use PHP 5.4.x, setting mbstring.http_input from "auto" to "pass" may solve your problem.
Reinstalling apache and recompile php fixed it for some ppl on linux.
I had the same on my localhost, but on the production server this does not happen. My local is WAMP, production is LAMP, everything has the same version.
So to me it works with these: CentOs 6.3, php 5.4, Apache 2.2.15
Btw, on my local, mb_detect_encoding() showes 'UTF-8' but the string is mess anyway.

UTF-8 Character set CentOS PHP

I've a problem with the utf-8, I'm trying to show russian characters over my page, but I'm getting ???? instead of those russian characters.
I tried to modify .htaccess like AddDefaultCharset UTF-8 but didn't work.
I also observed that when I try to show characters using .html extension (no php) it works fine, but with the php file is shows ?????.
server details
php 5.3.16
centos release 6.3
I've similar problem as here
http://remository.com/forum/func,view/id,18483/catid,24/
Thanks
adding these lines in main php.ini worked for me
default_charset = "utf-8"
mbstring.internal_encoding=utf-8
mbstring.http_output=UTF-8
mbstring.encoding_translation=On
mbstring.func_overload=6

Categories