How To Write An Encoding

Table of contents:

How To Write An Encoding
How To Write An Encoding

Video: How To Write An Encoding

Video: How To Write An Encoding
Video: Code Pages, Character Encoding, Unicode, UTF-8 and the BOM - Computer Stuff They Didn't Teach You #2 2024, May
Anonim

Until absolutely all documents on the network use the same UTF (Unicode Transformation Format) character set for all countries and peoples, it is imperative to indicate the encoding used in HTML or XML documents. Otherwise, pages that are quite normally displayed in your browser may transform into the notorious unreadable "crackers" in the Internet browsers of your site visitors.

How to write an encoding
How to write an encoding

Instructions

Step 1

The meta tag, which indicates the encoding used in the document, should be placed within the head element as close to the top of it as possible. This is the wording of the W3C (The World Wide Web Consortium), which develops and implements technology standards for the Internet. This tag itself in an HTML document may look like this: This directive must be used in pages written according to the HTML 4.01 and XHTML 1.x standards. For an XHTML document, the final bracket ">" must be replaced with "/>". In this sample, charset = is followed by the Unicode UTF-8 encoding. Of course, you need to replace UTF-8 with your value - the one in which this document was saved, or in which its contents are retrieved from the database. For the Russian alphabet, except for utf-8, these can be values windows-1251 (the most common), koi8-r, koi8-u, iso-ir-111, iso-8859-5, x-cp866, ibm855, x-mac -cyrillic.

Step 2

To specify the encoding in the site page - open the required document for editing. Find out what syntax the page code corresponds to - it is indicated at the very beginning, in the <! DOCTYPE … tag. Depending on the standard used (HTML or XHTML), prepare the tag code based on the above data. Then find the tag in the source of the page - usually the encoding indication is placed immediately after it. If for some reason there is no such tag in the code of your document, then find the tag that opens the heading part of HTML -. Paste the prepared code after it and save the document.

Step 3

If the pages use external CSS-style files and these files have elements using characters from national alphabets, then they should also indicate the encoding used. In the first line of the style file, add: @charset "windows-1251"; replace windows-1251 with the value you want. You can also specify the encoding that the browser should use when following the link. To do this, put the charset attribute with the desired value in the link tag. For example: How Simple!

Recommended: