html symbols and unicode

D

dalei

My question is presented more clearly in following web page:

http://www.pinyinology.com/signs2.html

<html>
HTML entities display outside script tags:
a&sup1;, a&sup2;, a&sup3;, a⁴

But unicode doesn't display outside script tags:
a\xb2, a\xb3, a\u2074

<script type='text/javascript'>

//Both HTML symbols and unicode display within script tags:

document.write ('a&sup1;, a&sup2;, a&sup3;, a⁴');

//and

document.write ('a\xb2, a\xb3, a\u2074');
</script>

Question: lucida sans unicode is declared within the style tags, why
unicode doesn't work outside script tags?
</html>
 
W

web.dev

dalei said:
My question is presented more clearly in following web page:

http://www.pinyinology.com/signs2.html

<html>
HTML entities display outside script tags:
a&sup1;, a&sup2;, a&sup3;, a4

But unicode doesn't display outside script tags:
a\xb2, a\xb3, a\u2074

Of course not. \xXX and \uXXXX is an escape sequence in javascript.
<script type='text/javascript'>

//Both HTML symbols and unicode display within script tags:

document.write ('a&sup1;, a&sup2;, a&sup3;, a4');

//and

document.write ('a\xb2, a\xb3, a\u2074');
</script>

Question: lucida sans unicode is declared within the style tags, why
unicode doesn't work outside script tags?
</html>

To use unicode most effectively in your html, use numeric ampersand
entities. For example: ² is equivalent to &sup2; and ³ is
equivalent to &sup3.

Hope this helps. :)
 
R

RobG

dalei said:
My question is presented more clearly in following web page:

http://www.pinyinology.com/signs2.html

<html>
HTML entities display outside script tags:
a&sup1;, a&sup2;, a&sup3;, a⁴

But unicode doesn't display outside script tags:
a\xb2, a\xb3, a\u2074

<script type='text/javascript'>

//Both HTML symbols and unicode display within script tags:

document.write ('a&sup1;, a&sup2;, a&sup3;, a⁴');

//and

document.write ('a\xb2, a\xb3, a\u2074');
</script>

Question: lucida sans unicode is declared within the style tags, why
unicode doesn't work outside script tags?
</html>

This question would be much better answered in an HTML forum, try:

comp.infosystems.www.authoring.html

My attempt is that when a character sequence &...; is parsed by the
browser's HTML parser an attempt is made to map it a character. If it
can't be mapped, then the literal characters are displayed.

e.g. &gt; becomes a 'greater than' symbol, but &tg; displays as
written because it can't be resolved into some special character.

The character sequence \x... is not understood by the browser's parser
(though I guess somewhere someone may have a browser that does) so it is
printed as is.

document.write attempts to resolve sequences like \x... and if possible
substitutes the appropriate character. I guess it uses the character
encoding for the page to work out which character to display for a
particular value.

You may find the following very useful for understanding character
encodings and repertoires:

<URL:http://ppewww.ph.gla.ac.uk/~flavell/charset/checklist>


As for UNICODE, it specifies a certain mapping between numbers and
characters. You may find this useful:

<URL:http://www.unicode.org/unicode/standard/principles.html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top