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

Re: [PATH/RFC] parse-options: report invalid UTF-8 switches

From
Erik Faye-Lund <kusmabite@gmail.com>
Date
Feb 11, 2013, 14:27 UTC
Message-ID
<CABPQNSaKt6XGwRBMNw1eHNCY-d0TY=63LwcnQsFKdnhA+JTL-w@mail.gmail.com>
In-Reply-To
<vpqy5ev7xpp.fsf@grenoble-inp.fr>

On Mon, Feb 11, 2013 at 3:05 PM, Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> wrote:

Show 10 quoted lines
> Erik Faye-Lund <kusmabite@gmail.com> writes:
>
>> But isn't UTF-8 constructed to be very unlikely to clash with existing
>> encodings? If so, I could add a case for non-ascii and non-UTF-8, that
>> simply writes the byte as a hex-tuple?
>
> If it's non-ascii and non-UTF-8, I think you'd want to display the byte
> as it is, because this is how it was entered. IOW, I'd say we should
> keep the current behavior in this case.
>

Yes, you are of course right. We should detect UTF-8, and only in those cases do anything special. Because the likely alternatives are other 8-byte encodings (which the terminal already should grok, since the user was able to input it), or other multi-byte sequences (which already is broken, and is tricky to handle). So at least we'd only break in very unlikely cases.

But, I wonder, could mbrlen be used to detect the length instead? It consults LC_CTYPE to find out what encoding to use, which seems like it might give the correct answer in all non-corrupted cases... I'm far from an expert on UNIX-internationalization, though. And this approach is likely to break on Windows, but I suspect that we can perform some well-placed hack for it, as we already know that we're doing UTF-8 there.

Previous: Matthieu MoyNext: Torsten Bögershausen
Message 5 of 13 in “[PATH/RFC] parse-options: report invalid UTF-8 switches”
  1. Erik Faye-LundFeb 11, 2013
  2. Matthieu MoyFeb 11, 2013
  3. Erik Faye-LundFeb 11, 2013
  4. Matthieu MoyFeb 11, 2013
  5. Erik Faye-LundFeb 11, 2013
  6. Torsten BögershausenFeb 11, 2013
  7. Erik Faye-LundFeb 11, 2013
  8. Torsten BögershausenFeb 11, 2013
  9. Junio C HamanoFeb 11, 2013
  10. Erik Faye-LundFeb 11, 2013
  11. Jeff KingFeb 11, 2013
  12. Erik Faye-LundFeb 11, 2013
  13. Junio C HamanoFeb 11, 2013

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.