Live data from Hacker News

A stray "j" ruined my evening

napkins.mtmn.name

21–30 of 36 posts

Re: A stray "j" ruined my evening

#21

A stray "J" I encountered years ago: a certain client's support tickets would often end with a single "J", which was a little confusing as it was not one of their name initials. After a brief investigation, the original email source contained this: J Which renders as a smiley face.

On seeing just the title, before reading the article, I assumed it was about the Wingdings J.

Re: A stray "j" ruined my evening

#22
I was poking around with this and I noticed wl-copy has an option to trim newlines. Maybe that's why they added the option but I'm leaning towards gurk being the culprit. wl-copy itself seems to handle newlines ok, at least for me. This works as expected:

  echo -e "test\n" | wl-copy

  wl-paste

Re: A stray "j" ruined my evening

#23
post #5

Earlier quoted context omitted.

\n is ^J (ctrl-J) so there's some logic there, but I wonder if something has been lost in the message. I'd guess it either displays ^J or an inverse-colour J, rather than just a plain lowercase j. Also possible that the j is a red herring and just some random character that's always there. Pasting a URL containing a newline into most browsers just truncates it at the newline, regardless of how much text is after. I o…

> \n is ^J (ctrl-J) so there's some logic there The same 'j' as vi uses for 'hjkl'. https://vi.stackexchange.com/questions/42426/why-did-vi-use-...

No, it's ^J because `J` is 0x4A in ASCII and `\n` is 0x0A, just as `I` is 0x49 and `\t` (tab, ^I) is 0x09.

In the stone age, pressing CTRL flipped that bit, so ^J is literally "ctrl-J".

Re: A stray "j" ruined my evening

#25

Earlier quoted context omitted.

> \n is ^J (ctrl-J) so there's some logic there The same 'j' as vi uses for 'hjkl'. https://vi.stackexchange.com/questions/42426/why-did-vi-use-...

also the same 'j' found in words like 'jujuism', 'jejunities', and 'bejeezus', also by a magical coincidence the same one in most Latin fonts, and even some random text strings such as 'pj$4' But I suppose you're saying ASCII 10 was chosen as newly because it aligns with the down arrow on keyboards of the time. Maybe.

> I suppose you're saying ASCII 10 was chosen as newly because it aligns with the down arrow on keyboards of the time. Maybe.

The linked StackExchange has it as:

> What character was used for what control code was mostly a matter of bitwise arithmetics. LF is ^J because J happens to be at the corresponding location in the corresponding column of the table (+ 64 in decimal)

Re: A stray "j" ruined my evening

#26

Earlier quoted context omitted.

> \n is ^J (ctrl-J) so there's some logic there The same 'j' as vi uses for 'hjkl'. https://vi.stackexchange.com/questions/42426/why-did-vi-use-...

No, it's ^J because `J` is 0x4A in ASCII and `\n` is 0x0A, just as `I` is 0x49 and `\t` (tab, ^I) is 0x09. In the stone age, pressing CTRL flipped that bit, so ^J is literally "ctrl-J".

You're saying the same thing. vi uses ‘j’ because the ADM-3A printed ‘­­↓’ on the ‘­J’ key because Control-J is newline because the code is J with a bit flipped because bit-flipping was practical on an electromechanical teletype.

Re: A stray "j" ruined my evening

#27

Earlier quoted context omitted.

> \n is ^J (ctrl-J) so there's some logic there The same 'j' as vi uses for 'hjkl'. https://vi.stackexchange.com/questions/42426/why-did-vi-use-...

also the same 'j' found in words like 'jujuism', 'jejunities', and 'bejeezus', also by a magical coincidence the same one in most Latin fonts, and even some random text strings such as 'pj$4' But I suppose you're saying ASCII 10 was chosen as newly because it aligns with the down arrow on keyboards of the time. Maybe.

Other way around. ASCII classified control characters into blocks and newline ended up a bit-flip away from J, so the ADM-3A printed ‘­↓’ on the ‘­J’ key.

Re: A stray "j" ruined my evening

#29

> but in ANSI newline delimiter is translated as "j" ?

the ANSI escape sequences for screen erasing start with ESC and end in J. When you display a string on a screen including a newline at the end of it, you need to erase to the end of the line on the screen so you don't leave predecessor garbage which would be confusing.

That's how the J got inserted, then whatever is processing this is swallowing the rest of the escape sequence but leaving the J. The fix is there, take the J with the rest of the escape sequence at whatever layer is doing this.

  ESC[J   erase in display (same as ESC[0J)
  ESC[0J  erase from cursor until end of screen
  ESC[1J  erase from cursor to beginning of screen
  ESC[2J  erase entire screen
  ESC[3J  erase saved lines
ASCII and then ANSI were invented as in-band communications and terminal control protocols, not "file formats". You thread filters together like beads on a string, where ASCII is somebody's job, and ANSI is somebody's job, and then the rendered text is presented to the user.

unix is ingenious how it has accomodated changes and conflicting ideas, incorporating the new squoze next to the old, like UTF-8 because the same people did that. It's not perfect, but it proved "worse is better" because it for a long time it outcompeted its alternatives and never became bloated and overburdened by bureaucratic committee ideas.

however today's developers did not "come up" in the same culture of apprenticeship learning so a lot of the clever subtlety has been lost and now worse is starting to be worse, and guess what, there is no better.

Post reply on HN