Join the discussion

Write your take first — we'll ask for email only when you're ready to publish.

  • Hacker News
  • As a vim user, stray J's are a fact of life.
  • 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
  • So this is a bug in that Signal TUI he was using? I.e. it mangles newlines in pasted text.
  • Impossible, Signal TUI is written in Rust.
  • If it's any consolation, the other day I spent 3 hours diagnosing a homebrew circuit board for no signal and finally realized the Raspberry Pi sending the signal had a dead GPIO pin.
  • I like how -j fixed the stray j problem....
  • Today I learned that jq -Rrj is a shorter command line for doing the same as tr -d '\n'.
    by rav
  • > but in ANSI newline delimiter is translated as "j"

    ?

  • I thought it was a strange way to express the problem, too. OP didn't really explain where or how the clipboard text was getting pasted in order to reproduce the issue.
  • Yeah, I don't understand this. What broken tool is turning newlines into 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.

  • This comes up fairly often in TeX, where you can use ^^J to insert a newline character [0]. For example, the following code:

      \message{before ^^J after}
    
    prints the following message:

      before 
      after
    
    This is common in other old software too [1] [2], but TeX is where I see it the most often these days.

    [0]: https://tex.stackexchange.com/a/64848/270600

    [1]: https://superuser.com/q/212874

    [2]: https://en.wikipedia.org/wiki/Caret_notation

  • \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.

  • 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:

        <font face="Wingdings">J</font>
    
    Which renders as a smiley face.
  • I remember discovering this in about 2010, and thought it was hilarious
  • Seemed to be a common occurrence from Microsoft Outlook users.
  • On seeing just the title, before reading the article, I assumed it was about the Wingdings J.