Html charset and support for special (national) characters - html

I have a website in HTML5. Most of the content there is in Czech, which has some special symbols like "ř, č, š" etc...
I searched the internet for recommended charsets and I got these answers: UTF-8, ISO 8859-2 and Windows-1250.
<meta http-equiv="Content-Type" content="text/html; charset=ISO 8859-2" />
I tried UTF-8 which didnt work at all and then settled up with ISO 8859-2. I tested my website on my computer in the latest versions of Chrome, Firefox, IE and Opera. Everything worked fine but when I tested my website at http://browsershots.org/ , these characters were not displayed correctly (in the same browsers that I used for testing!).
How is that possible? How can I ensure, that all characters are displayed correctly in all web browsers. Is it possible that usage of HTML5 causes these problems (since its not fully supported by all browsers, but I am not using any advanced functions)?
Thanks for any hints and troubleshooting tips!

If you using HTML5, try this short declaration of charset:
<meta charset="UTF-8">
Additionally check you html file encoding. You can do it in Notepad++, menu Encoding -> Encode in UTF-8.

The important thing is that the actual encoding of the data coincides with the declared encoding. From the description, it seems that the actual encoding is ISO-8859-2, so you should declare it. Note that the name of the encoding has no space but hyphens. (I wonder whether you used it with a space – I would expect browsers to ignore the tag then.) The following is the simplest declaration:
<meta charset=ISO-8859-2>
I would not trust on browsershots.org getting things like this right. Testing on actual browsers is more useful.

UTF-8 is the best-supported character set for international usage. If it does not display correctly, you should ensure that your file is saved in UTF-8 format. Even Notepad has a "UTF-8" option in its save dialog.

Related

Unable to display properly charset ibm850 in Firefox

I have some HTML file generated by an old software. It writes files in cp850 (aka ibm850). It puts this at the top of the file:
<HEAD>
<META http-equiv=Content-Type content="text/html; charset=ibm850">
The file is itself writing to disk using cp850 encoding (i.e. if I open it in Notepad++ for example, it's properly recognized as such).
In Internet Explorer, this file shows properly. In Firefox 46, I get some wrong characters. For example, I get ÄÄ instead of ──.
I tried various aliases for IBM850 per the Mozilla CharSet Aliases document, but none worked.
Is that a problem in Firefox? Or is that a problem with the HTML? Is there a way to solve this?
It turns out, Mozilla dropped support for CP850 4 years ago in version 19. A whole bunch of encodings were dropped as they were very old.
Bug 846936 - Non-ASCII characters not displayed correctly in encoding IBM850 (and possibly others?)

japanese character is not supported in localhost

I have a project which has japanese characters in it. When I run the project which is already on the server (the live version) japanese characters are displayed. However, the same files with no changes in the code, if I run on localhost then japanese characters are displaying something like this "レストラン".
all files includes . and i'm using google chrome.
what should I do to make it support japanese characters?
any help would be appreciated.
Add following:
<meta charset="Shift-JIS"/>
to your file if you use HTML5, or
<meta http-equiv="Content-Type" content="text/html; charset=Shift-JIS" />
if you use HTML 4.01.
The reason why it works over the webserver is because it transmits HTTP headers with correct encoding. On your local copy of .html, there are no such headers, so the browser checks the <meta/> tags (which are missing), and if it fails to find these, it guesses encoding, which in this case is UTF8. (If you use webserver in localhost too, it might be misconfigured. In any case, it's a good practice to always include charset information.)
#AshishAcharya I'm pretty sure OP uses Shift-JIS rather than UTF8. The page is rendered as UTF8 though.

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.

IE 10 does not load page in UTF-8

I've got simple HTML pages in Russian with a bit of js in it.
Every browser going well except IE10. Even IE9 is fine. Next code is included:
<html lang="ru">
<meta http-equiv="Cоntent-Type" content="text/html"; charset="utf-8">
Also I've added .htacess with
AddDefaultCharset UTF-8
Still IE10 loads page in Cyrillic encoding (cp-1251 I believe), the only way to display characters in a right way is to manually change it to UTF-8 inside of a browser (or chose auto-detect mode).
I don't understand why IE10 force load 1251 instead of UTF-8.
The website to check is http://btlabs.ru
What really causes the problem is that the HTTP headers sent by the server include
Content-Type: text/html; charset=windows-1251
This overrides any meta tags. You should of course fix the errors with the meta tag as pointed out in other answers, and run a markup validator to check your code, but to fix the actual problem, you need to fix the .htaccess file. Without seeing the file and other server-side issues, it is impossible to tell how to fix that (e.g., server settings might prevent the effect of a per-directory .htaccess file and apply one global file set by the server admin). Note that the file name must have two c's, not one (.htaccess, not `.htacess').
You can check what headers are e.g. using Rex Swain’s HTTP Viewer.
The reason why things work on other browsers is that they apply the modern HTML5 principle “BOM wins them all”. That is, an HTTP header wins a meta tag in specifying the character encoding, but if the actual data begins with three bytes that constitute the UTF-8 encoded form of the Byte Order Mark (BOM), then, no matter what, the data will be interpreted as UTF-8 encoded. For some unknown reason, IE 10 does not do that (and neither does IE 11).
But this won’t be a problem if you just make the server send an HTTP header that declares UTF-8.
If the server has been set to declare windows-1251 and you cannot possibly change that, then you just need to live with it. Transcode your HTML files to windows-1251 then, and declare windows-1251 in a meta tag. This means that if you need any characters outside the limited repertoire representable in windows-1251, you need to represent them using character references.
perhaps because your 'o' in 'content' is not an ascii 'o'. notice that it is not red in Stackoverflow? i then copied it to a good text editor and see that it is indeed not an o. because the 'o' is not really an ascii 'o', that whole line probably should get ignored in every web browser, which should then depend on what default charset it uses. Microsoft and IE is notorious for picking bad defaults, thus is my reason why it doesn't work in IE. ;)
but codingaround has good advice too. it's best to put quotes around your attribute values. but that should not break a web browser.
you should use a doctype at the start:
<!DOCTYPE html>
<html lang='ru'>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
but the real culprit is your content and charset problem. notice my line. mine is very different. ;) that's the problem. note that mine has two ascii 'o's, one in "Content-Type" and another in 'content='.
As Shawn pointed out, copy and paste this:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
This is a really good example of how non-Ascii letters that look like English Ascii letters can really mess things up!
Maybe you forgot changing cоntent=text/html; to cоntent="text/html";
As Shawn has already pointed out, it could also be content="text/html; charset=utf-8".
But as you have tried both things out, can you confirm if the IE10 output looks like this?
I can't really help further with this, as the only thing I have here is an IE 10 online emulator.
So far the possible problems are:
Different o character
I see, that the <meta> tag is still outside of <head>, put it in place
Problems with IE handling the content and charset attributes

Is there a way to enable Unicode characters in all browsers on Windows XP?

I'd like to use unicode symbols within my website (especially Dingbats).
Is there any way to enable this inside all (or at least some) browsers in Windows XP, without having the user to adjust any of his settings?
I use the HTML5 doctype with the charset configured to UTF-8:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
</head>
<body></body>
</html>
The browsers recognize the charset correctly (even IE7). But no special characters are displayed. I only see an empty square box.
This is the case for all of the following browsers: IE7, Safari 4, Firefox 3.5, Chrome 4.1, Opera 10.51.
So, is there any way to configure to enable all (or most) unicode characters for browsers running on Windows XP?
I ended up using graphics instead of Unicode characters. That was the only way I could be sure it looks as expected across all browsers and operating systems.
<'meta http-equiv="content-type" content="text/html; charset=UTF-8" />'
copy and paste the above meta tag in your head section.
I'm going to ask a Microsoft worker mate for a solution. Maybe he know the way... Until the answer will come try windows-65001 instead of UTF-8.
The windows-65001 is equal to UTF-8, but got another name. Maybe it counts for the old systems.