0

Is this a pbcopy command garbled bug? If so, is there a way to fix it?

I've tried a few ways but still can't found why this is happened.

update

open it in the terminal is ok, but garbled when open it in a file editor(vscode)

# ✅ terminal
$ cat man-grep.md

# ❌ vscode
$ code -n man-grep.md

vscode toggle UTF-8/UTF-16 both not work at all?

screenshot gif https://cdn.xgqfrms.xyz/Linux/unicode-garbled-bug.gif

error / bug

Steps to reproduce

# 1. copy output
$ man grep | pbcopy

# 2. paste to a markdown file

# 3. view the markdown file

enter image description here

using vscode open the markdown file, still garbled

enter image description here

template solutions

  1. output to a markdown file
# stdout
$ man ls > man-ls.md
# $ man grep > man-grep.md

# no pagination problem ✅
$ cat man-ls.md
# $ cat man-grep.md

enter image description here

  1. manually copy & paste (page by page )
# copy man docs, page by page
$ man grep

enter image description here

xgqfrms
  • 10,077
  • 1
  • 69
  • 68
  • 1
    No, `grep` doesn't detect if it's writing to a terminal, file, or pipe. The characters you see in the file are ASCII backspace characters, which pagers recognize as a form of overstriking. (N, backspace, N on a typewriter would type an N over an existing N, making it darker, so a pager will recognize it as a signal to display that text in boldface.) – chepner Nov 21 '22 at 18:36
  • vscode toggle UTF-8/UTF-16 both not work at all? (screenshot gif) https://cdn.xgqfrms.xyz/Linux/unicode-garbled-bug.gif – xgqfrms Nov 21 '22 at 19:08

1 Answers1

0

vscode solution ✅

use vscode to fix copy from the terminal encoding bug

steps

  1. export one .md markdown file
# export
$ man shutdown > shutdown.md
# $ man grep > grep.md

  1. open exported .md file with vscode

  2. select all " symbols, and press the backspace/back delete key twice ()

That's all.

gif demo

enter image description here

xgqfrms
  • 10,077
  • 1
  • 69
  • 68