- Just UTF-8!這該算是資訊界難得的共識吧。
- UTF-8 是一種不固定長度的編碼方式,原定義在 ASCII (128 以下) 佔用 1byte,而其它語言的字元則佔 2、3或4個 bytes。
- 漢字在 UTF-8 中佔 3 bytes ,相較於用 Big5(字元固定 2 bytes)編碼的文件,其所佔用的空間較多。
- 時至今日,大多的編輯器都能正確支援 UTF-8。唯一要注意的是:不要寫入 BOM,像是 Windows 內建的 Notepad 在轉存 UTF-8 格式時會自動在檔案頭開插入 EF BB BF ,雖然在支援 UTF-8 編輯器不會顯示出來,但這會造成一些問題(如驗証 HTML 時會出錯)。
- Byte-order mark - Wikipedia, the free encyclopedia
- 在 HTML 中使用 UTF-8
- 在<head> 中插入:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>標題</title>
- 使用 UTF-8 的網頁在 IE 中有可能會出現一片空白的情況,所以要將字元集的宣告放在 <title> 之前。
- :::zonble's promptbook » 一片空白的UTF-8網頁:::
- 在<head> 中插入:
- 在 XML/XHTML 中使用 UTF-8
- 在文件開頭插入 XML 宣告:
<?xml version="1.0" encoding="UTF-8"?>
- 上述的 XML 宣告在 XML 文件中並不是必要的,但建議使用。
- Extensible Markup Language (XML) 1.0 (Fourth Edition) 2.8 Prolog and Document Type Declaration
- 在文件開頭插入 XML 宣告:
- 在 Apache 中使用 UTF-8
- 在 http.conf 文件中插入:
AddDefaultCharset utf-8
- AddDefaultCharset Directive - core - Apache HTTP Server
- 在 http.conf 文件中插入:
No comments:
Post a Comment
Comment Form Message