Log in

View Full Version : What is the tag to allow Japanese to be displayed via UTF?



Bubbletin
05-10-2007, 03:31 PM
I know there is some head tag to add to allow pages to display Japanese text but I'm not sure what it is as times have changed. Could someone please lead me in the right direction? Hopefully I'm asking the question right.. I remember using something with the term 'UTF-8' in it. Sorry I cannot provide more information.

mwinter
05-10-2007, 04:34 PM
I know there is some head tag to add to allow pages to display Japanese text but I'm not sure what it is as times have changed.

There isn't. Displaying any particular set of glyphs is dependent upon at least two things - I might be forgetting something. A visitor must have a set of fonts capable of rendering the glyphs. I, for example, can't read Japanese on this machine because none of the fonts installed here includes Kana or Kanji characters. The document must also be written using an encoding scheme that can represent the necessary character (and of course a user agent must be able to handle that scheme).



I remember using something with the term 'UTF-8' in it.

UTF-8 is one of the Unicode encoding schemes. Whilst most known characters can be expressed using UTF-8, it may be more efficient to use UTF-16. It depends how many characters from the U+00..7F range (7-bit ASCII) are included in the document.

Author your documents in an editor capable of reading and writing Unicode characters, and save those documents using either the UTF-8 or -16 encoding schemes. Upload them to your server and ensure that it will send the correct Content-Type header. How you accomplish this depends on the server you are using, and what ability you have to configure it.

Mike

Bubbletin
05-10-2007, 04:58 PM
I was asking the wrong question but I did figure it out, thank you for the reply and sorry for seeming like an ass but I'll post this for those looking:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

I added that and my browser rendered the Japanese properly, otherwise it came up as jibberish even with Japanese support installed. But that was my fault for wording the question incorrectly. Sorry and thanks again.

mwinter
05-10-2007, 05:05 PM
I was asking the wrong question

No, you weren't (I knew what you were asking), and my answer stands: don't use a meta element. Ensure that the server is sending the necessary information. A meta element should be a last resort.



<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

Don't use XML-like syntax in a HTML document.

Mike

Bubbletin
05-10-2007, 06:56 PM
When you say don't use XML-like syntax could you please elaborate for someone with limited html knowledge?

I'm more of a copy/paste type coder.. my kind is looked down upon by the great handcoders of the world but I can still get complex pages done and looking perfect in all browsers just requires more trial and error ^_- all your wisdom shared is very much appreciated.

mwinter
05-10-2007, 07:32 PM
When you say don't use XML-like syntax could you please elaborate for someone with limited html knowledge?

Serving XHTML as HTML on the Web seems to have become quite a popular thing to do, but not for any good reason. There are no advantages for users, and in fact it relies upon poor HTML processing implementations to even work properly (a correct SGML-based HTML processor would choke on this pseudo-XHTML). It's become so ubiquitous that even HTML documents can be found containing XHTML fragments.

The sort of thing that I'm referring to is code such as:



<img ... />
<meta ... />
<script ... src="..." />

These are legal within XHTML documents (if served as XHTML), but not HTML. The first two are actually equivalent to:



<tag ...>&gt;

That is, the element followed by a greater-than symbol (>). It's a rare thing to find a user agent that would act this way, but that's no reason to jump on this particularly wobbly wagon.

The last example is more serious though; it's the same as writing



<script src="..."></script>

in XHTML, but



<script src="...">&gt;

in HTML. The most important thing to note, though, is that there's no end-tag. Indeed, present this to IE and the document will break rather horridly.

You'll find quite a lot of material on the Web regarding serving XHTML as HTML. The most famous and frequently cited treatise is written by Ian Hickson (also known as Hixie) entitled sending xhtml as text html considered harmful (http://www.hixie.ch/advocacy/xhtml).

Mike


XHTML is an application of XML. That is, XHTML is rooted in the syntactic and semantic rules and conventions of XML.