unicode gibberish character in html - mysql

I am trying to rewrite old php mysql website in codeigniter, The site is in unicode, and text in database is stored like this
बेलायतम&.
when i pull data from database and display in html it appears like this
सरà¥à¤µà¥‹à¤šà¥à¤šà¤•à¥‹ à
It is fine in old site, I am using exactly as same header as old site in html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
I am banging my head how to correct text ?

Try this
<meta charset='utf-8'>

There should be a problem, html's codes you are using are right, just in case check if you can see proper characters on this website:
http://www.unicodeblocks.com/block/Devanagari
and make sure you are using:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Please double check it - use "view page source" on your page and check, maybe you used meta tag twice with different variables?
and one more...
if you are using db, please do this:
$mysqli->query('set character set utf8');

Related

Why are there random characters appearing in my code?

I create email flyers and for some reason I am getting weird characters appearing near others that aren't numerical or alphabetical. They seem to appear when I come back to the file at a later date, it doesn't happen as soon as I type.
I'm not sure if its something to do with my Doctype because it's the same as I've been doing for the past 2/3 years and I've only noticed this problem now happening over the past month or so.
My Doctype:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Here is an example of what I mean. These have appeared next to a £ and a '
Try giving your documents an HTML5 doctype:
<!DOCTYPE html>
and specifically declaring a character set of UTF-8:
<meta charset="utf-8">
Eg.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title> ...

Question marks '???' before doctype in HTML UTF-8 email, the rest of the document is fine

Im aware there are other posts on character encoding however this one appears to only occur before the doctype.
My original source is:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta content="telephone=no" name="format-detection">
<title>TITLE</title>
</head>
But it comes through in an email as (note the question marks at the start):
???<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta content="telephone=no" name="format-detection" />
<title>TITLE</title>
</head>
This seems strange as there are no characters or whitespace before the doctype. I don't really get 'what' can't be rendered. Also, the file was originally saved in visual studio using the following settings:
Any help much appreciated
There are actually characters before the doctype. As you have saved the file as UTF-8 with signature, it contains a BOM (byte order mark) at the beginning of the file.
Save it as UTF-8 without signature, and the characters will go away.
You don't have a *< / html > * tag ending the whole code. Try that. If it still isn't working, I suggest you use notepad++ instead of Visual Studio.

Correct doctype, attributes, encoding for Chinese language

How should I modify this in order to display Chinese characters?
Those question marks are actually Chinese writings.
Thanks
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
?????????????????????????????
????????????????
?????????????????????,?????????????,???!
</body>
</html>
I would making sure that your editor's character encoding settings match. (i.e. change the setting to UTF-8 and try retyping/repasting). For example, in Eclipse, IIRC, the default encoding for most files is dependent on your regional settings (it will usually pick a non-UTF variant such as ISO-8859-1 (Latin-1) - on my machine). Which editor are you using?

Why smart quotes look garbled in html

This is my htmlcode
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="en-us" http-equiv="Content-Language" />
<meta content="text/html; charset=windows-1252" http-equiv="Content-Type" />
</head>
<body>
“”
</body>
</html>
This is what I see in firefox “â€
I wonder why.
To write characters outside the standard ASCII set (which is common among almost all encodings) without using HTML entities, you have to make sure that the file is actually saved using the encoding that you specify in the meta tag.
Your page is saved as UTF-8 (the default), which means that those characters will be wrong when the browser tries to decode them as Windows-1252.
You need to use the HTML entities for smart quotes: “ for the left, ” on the right.
More info here.

How to insert XUL into a XHTML document

I have a XHTML document and want to embed XUL widgets into the document. What is the correct XML syntax to do so?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
insert XUL here
</body>
</html>
add xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" to your <html> tag.
then use <xul:element>, e.g. <xul:vbox>
Edit
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<xul:vbox>
</xul:vbox>
</body>
</html>
Also, I assume this isn't such a simple case... otherwise there wouldn't be much point in wrapping the xul in html (though the other way around does happen sometimes)
Edit
Some additional points to keep in mind when doing this:
must be served with a valid xml type. e.g. application/xml or text/xml -- not text/html. (See https://bugzilla.mozilla.org/show_bug.cgi?id=101147#c12 -- the whole thread is worth a read)
must be valid xml. A certain degree of sloppiness is tolerated by browsers when parsing html (unclosed tags, etc.) and this is not that case for a document containing xul (even the html parts of the document)
(thanks to Nikolay for the first point)