Why Unicode character for "Hearts" symbol fails with HTML
According to my understanding the following HTML markup should display a heart symbol, but it is not. What I am missing? I got the data about Unicode characters here: http://en.wikipedia.org/wiki/Html_special_characters#Character_entity_references_in_HTML
<?xml version="1.0" encoding="utf-8" ?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=u开发者_开发技巧tf-8" />
<title>Hearts</title>
</head>
<body>
੩
</body>
</html>
The XML/HTML &#NNNN;
notation is for decimal values. Try using the &#xNNNN;
form to force it to interpret it as hexadecimal, or, alternatively, use the decimal value.
Encoded entities:
♥ ♥ ♥
♡ ❤ ❥
Output:
♥ ♥ ♥ ♡ ❤ ❥
Note the x
required.
Without the x
:
੥ ੩
੩
<?xml version="1.0" encoding="utf-8" ?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Hearts</title>
</head>
<body>
♥
♥
</body>
Works in FireFox/Chrome/IE. Looks like you forgot the "x" bit in your code.
精彩评论