character encoding in a html page - html

I have 2 html pages (index.html and game.html) where I specify the same character encoding UTF-8
in the first page (index.html) every thing works fine but in the second page all characters appear like this �
this is the code of 2 pages :
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title> أصوات</title>
</head>
<body dir="rtl" lang='ar' class="contentBack">
</body>
</html>
the result in my browser:
how can I solve this problem ?

Make sure the file is also saved with the corresponding encoding (in your case UTF8). Setting the right meta charset may not be enough.

Related

Quotation marks inside <pre> element showing as “ or similar character

I'm just trying to post a simple html file consisting mainly of some prose I wrote inside of <pre> elements.
Interestingly, when I view the file on my computer with my browser, the quotation marks display fine. But when I upload it to my website, quotation marks are rendered as something like “ or â€. I have looked around the web for solutions but they were few and in between.
I tried to use the meta tag and included
<meta http-equiv="Content-Type" content="text/html; charset="utf-8" />
to my header but to no avail. Any ideas on how to solve this? It just wouldn't make sense to go back to the content inside the elements and code it into html as the prose is a draft and will go through many changes in the future.
The <!doctype html> tag indicates the file is HTML5 - so the browser will render it as such. lang="en" should be set to the language you are working with. Be sure to use the <meta charset="utf-8"> tag to set the character set in the <head>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Template</title>
</head>
<body>
<pre>This is my stuff</pre>
</body>
</html>
Check your code with the browser's View Source and use the Validator at https://validator.w3.org/ to check the page.
Here what I tried.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
<pre>Einstein said,"Once you stop learning, you start dying"</pre>
</body>
</html>
I also tried only this
<body>
<pre>Einstein said,"Once you stop learning, you start dying"</pre>
</body>
Still working

Garbled japanese title in html - SHIFT JIS

In my html code , where i use japanese signs - title ( only title ) is garbled . It's only in japanese environment (OS) .
Title shows as something like : �����i�A� . Body shows japanese signs .
I tried to set attributes like 'lang' but it doesn't work.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=SHIFT_JIS">
<TITLE>ヘルプ </TITLE>
</HEAD>
<BODY>
<H1>サーバリスト</H1>
サーバリスト画面では、
</BODY>
</HTML>
Why not use UTF8 and a simpler DOCTYPE?
You have to make sure your editor is actually saving in the codepage of the page.
Your page is fine when I save it as SHIFT-JIS and you must serve it as SHIFT-JIS - then it should work. So one of those are wrong
If you can use UTF-8 encoding. This works fine if the file itself is also encoded in UTF-8.
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>ヘルプ </title>
</head>
<body>
<h1>サーバリスト</h1>
サーバリスト画面では
</body>
</html>

Strange behavior of <a> tag

My code says
example.com
But when it comes to the browser, it looks like the following and the link is not working.
<a href="http: www.example.com"="">example.com</a href="http:>
Do you have any idea why this is happening?
Looks like you copied or accidentally added a blank space in the html. Simply set your cursor in front of the a and hit backspace till you hit the < ;-) Rinse and repeat for the closing bracket.
Make sure to specify a doctype and a charset on your HTML file. Also remember to save your file as ".html" or ".htm".
Here is a small example of a basic HTML structure.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Your document title</title>
</head>
<body>
Your code goes here.
example.com
</body>
</html>

Turkish characters does not display correctly

i have the following code. it contain Turkish content. but i get the results including special charecter. so please give solution for that.
html code
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<META HTTP-EQUIV="content-language" CONTENT="TR" />
<title>test</title>
</head>
<body>
Tarihçe
</body>
</html>
i will get Tarih�e instaed of Tarihçe.
If you can use Turkish encoding below will be the meta tag
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9" />
else code Tarihçe as
Tarihçe
Change the actual character encoding of the file to UTF-8, using whatever settings need to be used in the program you use to create and edit pages. The file is now in some 8-bit encoding, so the letter ç appears in the data as a byte that is not allowed in UTF-8; hence the � symbol (it indicates character-level data error).

How to not decode special characters in links?

If you save this file and hover over the link, firefox will decode %2F%2F to // and hence the link is broken.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
linux%2F%2Funix_servers.html
Are there ways to prevent the browser from decoding the special characters in links?
If the URL is to contain the real percent sign “%”, then by the applicable encoding rules, it must be %-encoded, as “%25”. Thus the URL should be written as linux%252F%252Funix_servers.html
It only displays the text of the link as // since %2f is a slash in HTML. The link itself is fine and should link to the file you had with no issue. Use % to represent a % in html.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
linux%2F%2Funix_servers.html
</body>