git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v8 4/7] utf8: add function to detect a missing UTF-16/32 BOM

From
Lars Schneider <larsxschneider@gmail.com>
Date
Feb 25, 2018, 11:41 UTC
Message-ID
<8EE59DC3-69E0-412B-AC50-5D348D6D5BE0@gmail.com>
In-Reply-To
<CAPig+cSX9uLWi++3pOis+iPGqEbrAL5px70CB-aUjDVGYZqweA@mail.gmail.com>
Show 33 quoted lines
> On 25 Feb 2018, at 04:52, Eric Sunshine <sunshine@sunshineco.com> wrote:
> 
> On Sat, Feb 24, 2018 at 11:27 AM,  <lars.schneider@autodesk.com> wrote:
>> If the endianness is not defined in the encoding name, then let's
>> be strict and require a BOM to avoid any encoding confusion. The
>> is_missing_required_utf_bom() function returns true if a required BOM
>> is missing.
>> 
>> The Unicode standard instructs to assume big-endian if there in no BOM
>> for UTF-16/32 [1][2]. However, the W3C/WHATWG encoding standard used
>> in HTML5 recommends to assume little-endian to "deal with deployed
>> content" [3]. Strictly requiring a BOM seems to be the safest option
>> for content in Git.
>> 
>> Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
>> ---
>> diff --git a/utf8.h b/utf8.h
>> @@ -79,4 +79,20 @@ void strbuf_utf8_align(struct strbuf *buf, align_type position, unsigned int wid
>> +/*
>> + * If the endianness is not defined in the encoding name, then we
>> + * require a BOM. The function returns true if a required BOM is missing.
>> + *
>> + * The Unicode standard instructs to assume big-endian if there
>> + * in no BOM for UTF-16/32 [1][2]. However, the W3C/WHATWG
>> + * encoding standard used in HTML5 recommends to assume
>> + * little-endian to "deal with deployed content" [3].
> 
> Perhaps you could tack on to the comment here the final bit of
> explanation from the commit message which ties these conflicting
> recommendations together. In particular:
> 
>    Therefore, strictly requiring a BOM seems to be the
>    safest option for content in Git.
Agreed. I'll change it.

Thanks, Lars

Previous: Eric SunshineNext: lars.schneider@autodesk.com
Message 16 of 20 in “convert: add support for different encodings”
  1. 0/7 convert: add support for different encodingslars.schneider@autodesk.com, Feb 24, 2018
  2. 1/7 strbuf: remove unnecessary NUL assignment in xstrdup_tolower()lars.schneider@autodesk.com, Feb 24, 2018
  3. 2/7 strbuf: add xstrdup_toupper()lars.schneider@autodesk.com, Feb 24, 2018
  4. 3/7 utf8: add function to detect prohibited UTF-16/32 BOMlars.schneider@autodesk.com, Feb 24, 2018
  5. Eric SunshineFeb 25, 2018
  6. Lars SchneiderFeb 25, 2018
  7. Eric SunshineFeb 27, 2018
  8. Lars SchneiderFeb 28, 2018
  9. 5/7 convert: add 'working-tree-encoding' attributelars.schneider@autodesk.com, Feb 24, 2018
  10. Eric SunshineFeb 25, 2018
  11. Lars SchneiderFeb 27, 2018
  12. Eric SunshineFeb 28, 2018
  13. 6/7 convert: add tracing for 'working-tree-encoding' attributelars.schneider@autodesk.com, Feb 24, 2018
  14. 4/7 utf8: add function to detect a missing UTF-16/32 BOMlars.schneider@autodesk.com, Feb 24, 2018
  15. Eric SunshineFeb 25, 2018
  16. Lars SchneiderFeb 25, 2018
  17. 7/7 convert: add round trip check based on 'core.checkRoundtripEncoding'lars.schneider@autodesk.com, Feb 24, 2018
  18. Eric SunshineFeb 25, 2018
  19. Lars SchneiderMar 4, 2018
  20. Eric SunshineMar 4, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.