13 ms·
\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, r
by ralferoo 3mo ago
\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 only know this from occasionally copying links from a terminal window where the copy somehow added newlines every 80 characters (even though copying this way normally works fine). I'd have to copy the URL with newlines into a text editor, remove the new lines and copy again to be able to paste it.
- thaumasiotes 3mo ago> \n is ^J (ctrl-J) so there's some logic there Specifically, J is the 10th letter of the alphabet and therefore ctrl-J is code for ascii 10. Same reason ctrl-D sends EOF and ctrl-I sends tab.
- mike_hock 3mo agoYes, but piping output containing newlines into wl-copy does not result in j's in the clipboard.
- randallsquared 3mo agoSome tool or library is interpreting the newline as two characters (as you note), and then a subsequent step is removing unprintable characters. Things like this used to frequently happen in shells, Perl, PHP, and so on.
- rgoulter 3mo ago> \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-hjkl-instead-of-jikl/42428#42428 https://vi.stackexchange.com/questions/42426/why-did-vi-use-...
- microgpt 3mo agoalso 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.
- rgoulter 3mo ago> 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)
- microgpt 3mo agoand did they choose that code because the J key had a down arrow printed on it?
- ahazred8ta 3mo agoNo, the Baudot / Western Union mechanical teletype code assignments were worked out in the late 1800s and early 1900s. This was later developed into ASCII. Computer keyboards came much later. https://en.wikipedia.org/wiki/Baudot_code https://en.wikipedia.org/wiki/Baudot_code
- kps 3mo agoOther 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.
- Joker_vD 3mo agoYes, and ADM-3A also had "↑" on the "K" key, because \013 is vertical tabulation (VT), and "→" on the "L" because \014 is form feed (FF). It all makes perfect sense. If terminfo database is to be believed, quite a lot of other terminals reused this control sequences too, for some reason.