Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Byte order mark
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===UTF-16=== In [[UTF-16]], a BOM (<code>U+FEFF</code>) may be placed as the first bytes of a file or character stream to indicate the endianness (byte order) of all the 16-bit [[Character encoding#Terminology|code units]] of the file or stream. If an attempt is made to read this stream with the wrong endianness, the bytes will be swapped, thus delivering the character <code>U+FFFE</code>, which [[Specials (Unicode block)|is defined]] by Unicode as a "[[{{Proper name|noncharacter}}]]" that should never appear in the text. * If the 16-bit units are represented in [[big-endian]] byte order ("UTF-16BE"), the BOM is the ([[hexadecimal]]) byte sequence <code>FE FF</code> * If the 16-bit units use [[little-endian]] order ("UTF-16LE"), the BOM is the ([[hexadecimal]]) byte sequence <code>FF FE</code> For the [[Internet Assigned Numbers Authority|IANA]] registered charsets UTF-16BE and UTF-16LE, a byte-order mark should not be used because the names of these character sets already determine the byte order. If there is no BOM, it is possible to guess whether the text is UTF-16 and its byte order by searching for ASCII characters (i.e. a 0 byte adjacent to a byte in the 0x20-0x7E range, also 0x0A and 0x0D for CR and LF). A large number (i.e. far higher than random chance) in the same order is a very good indication of UTF-16 and whether the 0 is in the even or odd bytes indicates the byte order. However, this can result in ''both'' false positives and false negatives. Clause D98 of conformance (section 3.10) of the Unicode standard states, "The UTF-16 encoding scheme may or may not begin with a BOM. However, when there is no BOM, and in the absence of a higher-level protocol, the byte order of the UTF-16 encoding scheme is big-endian." Whether or not a higher-level protocol is in force is open to interpretation. Files local to a computer for which the native byte ordering is little-endian, for example, might be argued to be encoded as UTF-16LE implicitly. Therefore, the presumption of big-endian is widely ignored. The [[W3C]]/[[Comparison of web browser engines (HTML support)|WHATWG]] encoding standard used in HTML5 specifies that content labelled either "utf-16" or "utf-16le" are to be interpreted as little-endian "to deal with deployed content".<ref>{{cite web | url=https://encoding.spec.whatwg.org/#utf-16le | title=UTF-16LE | publisher=WHATWG | work=Encoding Standard}}</ref> However, if a byte-order mark is present, then that BOM is to be treated as "more authoritative than anything else".<ref>{{cite web | url=https://encoding.spec.whatwg.org/#decode | title=Decode | publisher=WHATWG | work=Encoding Standard}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)