Utf-8 does not work in php file - html

I use notepad++ for coding.
I have a test.php file which is encoded with UTF-8 without boom. I have set the charset in the head as
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
However, if I open the file in a browser special characters like "äüö" are not represented correctly. If I go to pageinformation in firefox I get
Coding: windwos-1252
Content-Type text/html; charset=utf-8
Why is the coding wrong? How can I change it?

You should use notepad.exe which comes with windows and click SAVE AS option and change encoding there to utf-8 instead of ANSI. Save it and check.
I had similar issues.
Hope this helped

what about utf-8 without bom?
It happens with certain text editors. Try notepad++ or similar ones.

Related

Character encoding failing

I'm trying to set the encoding of some files in PHP to ISO-8859-1. I tried using this:
<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=ISO-8859-1">`
but it still isn't working. What can I do? Thank you.
You should be outputting this as a real HTTP header. <meta> elements are not a good substitute.
header('Content-Type: text/html;charset=iso8859-1');
You should ensure that the encoding of the files is actually ISO 8859-1 - all this does is tell the browser that the resource is in that encoding, it doesn't actually transcode or anything.

UTF-8 & ISO-8859-2 Problem

I've got a problem with html encoding. I work on PSPad. I set utf-8 as charset in my files and utf-8 as a file format and it look fine on localhost but doesn't on a server.
When i change file format to iso it works on a server but doesn't on localhost and when i close PSPad and reopen the file it totaly breaks some of the characters.
Do u have any solution? It so annoying! :)
thanks
K.
Make sure that the foreign server sends a charset declaration as well. What server software do you use? In Apache you could achieve it by adding a .htaccess file with the following content:
AddCharset utf-8 .html
Also make sure that you add a
<meta charset="utf-8">
declaration (HTML5) or a
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
To the HTML file header.
Edit: corrected typos

Charset UTF-8 doesn't work (stuck with these ?-marks)

I have a Unicode problem... I´ve done this before but for now, I cannot understand
why the Icelandic letters don´t show up - I have those question marks again
Here is the url (very plain and short html5)
http://nicejob.is/new/
Everything I Google says: use the <meta charset="utf-8"> as I do.
Any suggestions?
Your page is already viewed as UTF-8. But your source code is not saved as UTF-8.
Please change the encoding of your source code file to UTF-8.
Not all browsers support HTML5-way tags yet
here you can see table of compability
Try this instead:
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
I can see a couple of issues.
The META should look like this:
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
The <html> specified lang="en" which might be prone to confusing some browsers.
When I view the HTML from the browser, the question marks are encoded as 0xEF 0xBF 0xBD, which is the UTF-8 encoding for the byte order mark or BOM, aka U+FEFF. So, for whatever reason, the HTML is not transmitted as sensible UTF-8 (though it does seem to be valid UTF-8).
Probably you are using some text editor like notepad++,
and you didn't set up encoding to UTF-8 in that text editor.
What you have to do is to save the file with utf-8 encoding by using Notepad (the attached one with Windows).
Steps:
Save as ..
In the below options ... you will find encoding option choose UTF-8 ...
And save the file ...
Then add the line <meta charset="UTF-8" /> inside your file ...
And it will work.

€ symbol rendering as €2

Unusual problem here: I have an app that uses a text file which contains a few '€' symbols as well as other text in a text file to populate a mysql database. When rendered locally, the € symbol looks fine, but on the linux server and out on the web in html, it looks like this in some browsers:
€2
can anyone suggest a solution
Set the charset in the headers or a <META> element to UTF-8 so that it isn't processed as CP1250.
Use an UTF-8 encoding type on your file and make sure you add a content-type meta tag to your page:
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
Hope this helps !
If you are viewing your text (.txt) file as a text and not HTML in browsers window, setting
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
will not do the job as you are dealing with text file,
so tags will not be "hidden", plus it may potentially (even most likely) send garbage to mysql database you are trying to populate (e.g. by auto-harvesting posted online file).
So, if in browser window instead of:
€ 123.39
you are seeing
€2 123.39
problem is not with quality of your text file, but with the way browser handles encoding.
If you need to copy and paste displayed file and "€2" is in the way,
try simply setting your browser default encoding to unicode (UTF-8).
In FF you want to do it here:
Tools-> Options-> Content (tab)-> Fonts&Colors-> Advanced-> Default Char. Encoding
Once there select UTF-8 encoding.
Remember thou that sometimes page reload may not be enough to see changes, due to browser cache. In such case, restart your browser.

accented letters are not displayed correctly on the server, even if the encoding is correct

i wrote some html with utf-8 charset.
in the head of the html there is also a
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
everything works fine in local, but when i upload files to the server, i see all my letters
àèìòù etc
distorted.
anybody know how could it be the problem? is possible that the server force a charset that isn't utf-8?
thanks a lot
Try saving the actual file with utf-8 encoding. That did the trick for me.
I use PHPStorm as editor: File->File Encoding->utf-8
Actually the META tag is not all you need for correct UTF-8 encoding. Your server might still send the page as Content-Type: text/html; charset=ISO-8859-1 in the header of the page.
You can check the headers e.g. with the Live HTTP Headers Firefox add-on.
There is a lot of secret sauce with UTF-8 encoding and making it work, you might want to go through this page (UTF-8: The Secret of Character Encoding) which explains everything you need to know and gives you advice on how to solve encoding problems.
To answer your question: Yes it is possible to force the server to use UTF-8, e.g. by using the PHP headers() function like so:
header('Content-Type:text/html; charset=UTF-8');