Character encoding failing - html

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.

Related

hebrew characters don't show in "UTF-8 without BOM" only "UTF-8"

My html document starts as follows:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
אבגד
If I encode my document as UTF-8, it appears correctly in the browser. If I encode as UTF-8 without BOM (which I understand is more standard) I get unusual characters.
What am I doing wrong?
Your web server is declaring that the encoding is ISO-8859-1, and the browser is respecting that. Ironically enough, using a byte order mark sends a stronger signal to the browser that the encoding must actually be UTF-8. (The exact reason for this is complicated and boring.)
Fixing your web server depends on what the server is. If this is a static resource on disk served by Apache httpd, then something like AddCharset UTF-8 .html will add the header.
If this resource is served dynamically, then you should make sure you add the proper HTTP headers when producing the response, something like self.send_header('Content-Type', 'text/html; charset=utf-8') for Python's basic http server.

Utf-8 does not work in php file

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.

HTML5 Encoding & Cyrillic

Something that made me curious - supposedly the default character encoding in HTML5 is UTF-8. However if I have a plain simple HTML file with an HTML5 doctype like the code below, I get:
"hello" in Russian: "ЗдраÑтвуйте"
In Chrome 33+, Safari 6, IE11, etc.
<!DOCTYPE html>
<html>
<head></head>
<body>
<p>"hello" in Russian is "здраствуйте"</p>
</body>
</html>
What gives? Shouldn't the browser utilize the UTF-8 unicode standard and display the text correctly? I'm using Coda which is set to save html files with UTF-8 encoding by default so that's not the problem.
The text data in the example is UTF-8 encoded text misinterpreted as window-1252 encoded. The reason is that the encoding has not been specified and browsers are forced to make a guess. To fix this, specify the encoding; see the W3C page Character encodings. Two simple ways that work independently of server settings, as long as the server does not send wrong encoding information in HTTP headers:
1) Save the file as UTF-8 with BOM (there is probably an option for this in your authoring program.
2) Add the following tag into the head part:
<meta charset=utf-8>
There is no single default encoding specified for HTML5. On the contrary, browsers are expected to make guesses when no encoding has been declared. This is a fairly complex process, described in 8.2.2.2 Determining the character encoding.
If you want to be sure which charset will be used by browser you must have in your page head
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
otherwise you are at the mercy of local settings and browser automation.

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.

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');