Live data from Hacker News

The shortest pull request ever

github.com

41–50 of 55 posts

Re: The shortest pull request ever

#41
post #30

> If we drop those markers (1110 and 10 in front of bytes) and keep the remaining bits we're left with 1111111011111111, which evaluates to 65279, which is in hexadecimal 0xfeff. Yes, you recognize it, it's a BOM. Because yes a BOM is just a ZERO WIDTH NO-BREAK SPACE, isn't it beautiful? Byte Order Marks have stolen hours and days of my life. Anyone suffering the pain of developing on a windows box can relate. Window…

I've dealt with two elusive bugs which were ultimately caused by Windows stupidly using UTF-8 with BOM by default. Python requires you to take extra steps to decode that garbage, and some C++ libraries can't handle it at all. I'm sure there were good reasons that BOM sounded like the right idea at Microsoft, but everyone else just used straight UTF-8 and it was fine.

Windows supported Unicode in 1993 (NT 3.1) and 1995 (Win95) via UCS-2, a fixed-width 16-bit encoding.

In 1996, it was realized 16-bit wasn't enough, and was expanded in Unicode 2.0, which also included UTF-16, a variable-width encoding, which required the BOM.

Windows 2000 supported UTF-16 on release.

Why didn't Windows 2000 support UTF-8, which was invented in 1992 and implemented in Plan9 in that same year? Who can say...

Re: The shortest pull request ever

#42
post #38

> If we drop those markers (1110 and 10 in front of bytes) and keep the remaining bits we're left with 1111111011111111, which evaluates to 65279, which is in hexadecimal 0xfeff. Yes, you recognize it, it's a BOM. Because yes a BOM is just a ZERO WIDTH NO-BREAK SPACE, isn't it beautiful? Byte Order Marks have stolen hours and days of my life. Anyone suffering the pain of developing on a windows box can relate. Window…

I have written a cross platform, stand alone CLI program to inspect a file for BOM8 and BOM16. It also detects if a file uses CRLF or LF. Tab and nul characters are also evaluated. Please see the Examples in my repo: https://github.com/jftuga/chars

Love it!

Re: The shortest pull request ever

#43
post #5

Earlier quoted context omitted.

Depends on whether you consider `git commit --allow-empty` a weird quirk ... I guess it would be reasonable to do so ;).

What's the purpose of this? I can think of ways to use/abuse it, but there has to be a specific reason that it was added as a feature to git.

The most common reason I see it is to create the initial commit of a repo. This is useful both so you have something to push to a remote, PR against, and because several git commands (most notably rebase variants) need weird switches (eg --root) if you _don't_ have an empty initial commit to refer to instead.

Re: The shortest pull request ever

#44
post #40
post #37

Is there a tool to check for byte order marks, zero width spaces and other "weird" Unicode characters?

I wrote a cross platform, stand alone cli program to do this. It determines the end-of-line format, tabs, bom, and nul characters: https://github.com/jftuga/chars

Nice. Would it be possible to have an option to only output the names of files that failed the -f check? i.e. hide the names of files that look "normal" and show the "weird" ones.

Also, does it detect files that only contain CR as EOL characters? Or files that have different EOL characters on different lines?

Re: The shortest pull request ever

#45

Earlier quoted context omitted.

Back in 2014 I was trying to set up a Linux machine and bind it to the active directory domain at work. The active directory domain was a .local domain, but avahi Daemon thinks any packet that's bound for a DOT local address is addressed to it. So it would swallow up all the packets that were headed to the domain controller, look at them, think they were weird and not understand them and then drop them on the floor.…

Oof. On the other hand... > The active directory domain was a .local domain .local is a reserved domain for mDNS (aka ZeroConf or Bonjour, the stuff Avahi handles), standardized in early 2013. Then again, 2014 is soon enough after for that for knowledge not to have percolated everywhere, and/or for it to stomp on older networks that had used .local beforehand.

Microsoft recommended using .local for active directory domains since the 1990s, I think because back then it was not reasonable to demand that their customers register a domain name at a time when that was a massive hassle. But it was still wrong to squat on a TLD: there were already moves to expand the number of TLDs at the time, but MS were very slow to correct their mistake.

Then Apple made the same mistake with Bonjour / mDNS, and the IETF standardized Apple’s use of .local and it all became an even worse mess.

Re: The shortest pull request ever

#47
post #25

I mean, it's the shortest _possible_ pull request (since I don't think you can make a git diff of zero bytes, barring some weird quirk), but also probably has the highest PR description : PR diff length ratio of any PR I've seen.

Given that a BOM is three bytes, I don’t really agree that it’s the shortest. How about replacing a CRLF by LF? That one is invisible in many contexts as well.

…or removing a trailing LF at the end of a file where the last line is non-empty.

Re: The shortest pull request ever

#48
post #44
post #40

Earlier quoted context omitted.

I wrote a cross platform, stand alone cli program to do this. It determines the end-of-line format, tabs, bom, and nul characters: https://github.com/jftuga/chars

Nice. Would it be possible to have an option to only output the names of files that failed the -f check? i.e. hide the names of files that look "normal" and show the "weird" ones. Also, does it detect files that only contain CR as EOL characters? Or files that have different EOL characters on different lines?

I like the idea of only showing filenames that fail using -f so I created an issue for that. According to:

https://en.wikipedia.org/wiki/Newline#Representation

CR does not appear to really be used as EOL. Also, I don't think having different EOL chars within the same file is really a thing.

Re: The shortest pull request ever

#49
post #48
post #44

Earlier quoted context omitted.

Nice. Would it be possible to have an option to only output the names of files that failed the -f check? i.e. hide the names of files that look "normal" and show the "weird" ones. Also, does it detect files that only contain CR as EOL characters? Or files that have different EOL characters on different lines?

I like the idea of only showing filenames that fail using -f so I created an issue for that. According to: https://en.wikipedia.org/wiki/Newline#Representation CR does not appear to really be used as EOL. Also, I don't think having different EOL chars within the same file is really a thing.

Thanks for the issue, I've subscribed to it.

https://github.com/jftuga/chars/issues/2

According to the page, several machines and operating systems used CR as EOL. While the systems are all obsolete, files from that era that use CR as EOL could persist and be transferred to modern systems. Clearly those are weird on modern systems, so they should be warned about in a linting situation, which I would like to use your project 'chars' in.

Having different EOL chars within the same file is definitely a thing, usually by mistake. I had to fix a bug about this recently:

https://github.com/EionRobb/purple-discord/pull/416

Re: The shortest pull request ever

#50

Earlier quoted context omitted.

The original creator of the first zero width space had to be evil.

It has uses in typesetting, e.g. for allowing a word to be broken.

So what's the point of a zero width nonbreaking space then? seeing as that also exists.
Post reply on HN