2012-04-19 6:26, tlvp wrote:
> 1) How exactly do Notepad's UTF-8, Unicode, and Unicode Big-endian differ?
In Notepad, UTF-8 is UTF-8 with BOM. An easy way to check this out is to
launch Notepad, enter "foo", save as "UTF-8", and open the file in
Notepad++ (
http://notepad-plus-plus.org). The File format menu in
Notepad++ then shows the encoding; the menu has separately "UTF-8
(without BOM)" and "UTF-8". I think we can thus deduce what the latter
means. For further confirmation, if you right-click on the file icon in
Windows and select Properties, you'll see that the size is 6 bytes.
That's 3 bytes for the 3 Ascii letters plus 3 bytes for the UTF-8
representation of the BOM.
ObHTML: Contrary to widespread rumors around, even on W3C pages, the BOM
(Byte Order Mark, U+FEFF, at the very start of a document) is useful in
UTF-8 encoded HTML documents rather than a problem (which it used to be
in the previous millennium). Browsers have recognized it for a long
time. It acts as a useful "signature" that tells that the data is UTF-8
encoded, even in the absence of HTTP headers, XML prologues, meta tags,
and whatever.
"Unicode" in Notepad is UTF-16, more specifically UTF-16LE (little-endian).
Unicode big-endian is UTF-16BE. The difference between UTF-16LE and
UTF16BE is the byte order in 16-bit code units.
For completeness: The fourth option in the file formats in Notepad,
named "ANSI", has nothing to do with ANSI, the national standards
institute of the United States. "ANSI" is an intentional misnomer by
Microsoft and refers to whatever 8-bit encoding that is used as the
internal 8-bit encoding, depending on Windows version. None of those
encodings has ever been standardized by ANSI. In the Western world,
"ANSI" in this context is normally windows-1252.
2) Which of those (if any) does Wordpad's "Unicode" correspond to?
UTF-16LE. This is generally what "Unicode" means in Windows software,
unless stated otherwise.
> 3) which of those will give the sort of file that, other factors not
> precluding it, the site
validator.w3.org will agree is deserving of the
> following META tag (in the HEAD element)? -- :
>
> <meta http-equiv=Content-Type content="text/html; charset=UTF-8">
>
> I'd always assumed it was only Notepad's UTF-8 files, that both Notepad and
> Wordpad could open and resave nondestructively.
That is correct.
> Now I'm starting to wonder:
> will Wordpad's Unicode Text Documents work just as well?
No, it won't. It would require UTF-16 instead of UTF-8. Some browsers
support UTF-16, some don't. There are remarkably few UTF-16 encoded
documents on the web. Even though modern browsers generally cope with
them, there's no good reason to use UTF-16 for HTML documents on the
web, because UTF-8 is equally expressive and favored by IEEE, W3C, etc.
For some types of text data, UTF-16 saves space and thus bandwidth when
compared with UTF-8, but such concerns are hardly significant enough.
--
Yucca,
http://www.cs.tut.fi/~jkorpela/