Unicode
文字符号化スキーム
UTF-7
UTF-8
CESU-8
UTF-16
UTF-32
UTF-EBCDIC
SCSU
Punycode (IDN/IDNA)
GB 18030
その他
UCS
マッピング
書字方向
BOM
バイト順マーク (バイトじゅんマーク、英: byte order mark) 、バイトオーダーマークあるいはBOM(ボム)は、Unicodeの符号化形式で符号化したテキストの先頭につける数バイトのデータ。元にUnicodeで符号化されていることおよび符号化の種類の判別に使用する。 プログラムがテキストデータを読み込む時、その先頭の数バイトからそのデータがUnicodeで表現されていること、また符号化形式(エンコーディング)としてどれを使用しているかを判別できるようにしたものである。[1] Unicodeが開発された当初は、アメリカではASCII、ヨーロッパなどではISO-8859、日本ではShift_JISやEUC-JPといった他の文字コードが主流であり、使用されている符号化方式がUnicodeのものであることを明示する必要があった。また、Unicodeの符号化方式は複数あり、特にUTF-16やUTF-32にはそれぞれエンディアンが異なる2種類があるため、符号化方式同士を区別する必要があった。その方法として、先頭のデータにテキスト以外のデータを入れることが発案された。 実際にBOMを使用すべきか、あるいは使用すべきでないかは、Unicodeを利用したより上位の仕様によって定められることがある。"XML Media Types" (.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation.cs-ja1 q,.mw-parser-output .citation.cs-ja2 q{quotes:"「""」""『""』"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free a,.mw-parser-output .citation .cs1-lock-free a{background:url("//upload.wikimedia.org/wikipedia/commons/6/65/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited a,.mw-parser-output .id-lock-registration a,.mw-parser-output .citation .cs1-lock-limited a,.mw-parser-output .citation .cs1-lock-registration a{background:url("//upload.wikimedia.org/wikipedia/commons/d/d6/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription a,.mw-parser-output .citation .cs1-lock-subscription a{background:url("//upload.wikimedia.org/wikipedia/commons/a/aa/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("//upload.wikimedia.org/wikipedia/commons/4/4c/Wikisource-logo.svg")right 0.1em center/12px no-repeat}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:#d33}.mw-parser-output .cs1-visible-error{color:#d33}.mw-parser-output .cs1-maint{display:none;color:#3a3;margin-left:0.3em}.mw-parser-output .cs1-format{font-size:95%}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}RFC 3023 UTF-8は文字コードとしてASCIIを前提としたプログラムでもおよそ支障なく動作するように設計されているが、BOMによって正常に処理できなくなる場合がある。Unicodeの規格において、UTF-8においてBOMは容認されるが、必須でも勧められるものでもないとされている[4]。また、データベースやメモリにロードするデータなど、内部的なデータ形式では、プログラムの性能や効率の観点から普通BOMは用いられない。 BOMによってUnicodeのテキストデータが他のUnicode符号化形式や、BOMのバイト表現(UTF-7を除く)に符号位置に該当する文字のない日本語の文字コードから正確に区別をすることができる一方で、0xFEに"t"、0xFFに"y"が割り当てられているISO/IEC 8859-1に対しては、この2文字が先頭にくる文章を誤ってUnicodeと判断してしまう問題がある。 符号化形式(符号化スキーム)エンディアンの区別バイト順マーク (BOM) ゼロ幅ノーブレークスペース - U+FEFF の文字
概要
経緯
使用するべきか否か
各符号化形式(符号化スキーム)ごとのバイト順マーク
UTF-80xEF 0xBB 0xBF
UTF-16BE0xFE 0xFF
LE0xFF 0xFE
UTF-16BE(付加は認められない)
UTF-16LE(付加は認められない)
UTF-32BE0x00 0x00 0xFE 0xFF
LE0xFF 0xFE 0x00 0x00
UTF-32BE(付加は認められない)
UTF-32LE(付加は認められない)
UTF-70x2B 0x2F 0x76 ※ (※は次のバイトの値によって異なり、0x38、0x39、0x2B、0x2Fのいずれかがくる)
関連項目
脚注^ “ ⇒Unicode FAQ”. 2012年7月25日閲覧。
^ “ ⇒RFC [https://datatracker.ietf.org/doc/html/rfc3023 3023 - XML Media Types]”. 2012年7月25日閲覧。
^ 8.1. Character Encoding - STD 90 - The JavaScript Object Notation (JSON) Data Interchange Format
^ the Unicode Consortium, Julie D. Allen (2007). ⇒The Unicode Standard -- Version 5.0. p. 36. ISBN 0-321-48091-0. ⇒http://www.unicode.org/versions/Unicode5.0.0/ch02.pdf. "(from Chapter 2:General Structure) Use of a BOM is neither required nor recommended for UTF-8, but may be encountered in contexts where UTF-8 data is converted from other encoding forms that use a BOM or where the BOM is used as a UTF-8 signature"
Size:28 KB
出典: フリー百科事典『ウィキペディア(Wikipedia)』
担当:undef