Closed huhk-sysu closed 7 years ago
Thank you very much for your help. I had try your second way to fix this bug, but not work. Because using $imagePath directly always get ASCII output. I found this answer, so I use the following code to fix this bug.
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
[Console]::WriteLine($imagePath)
I'm using your extension, which has saved me much time.
Everything is fine before I tried to use it when the Markdown file was in a folder with Chinese letter in its name, which means the
imagePath
below may contain Chinese letter.I traced the execution of your extension and found the Chinese part of
imagePath
became a mess in the callback function ofsaveClipboardImageToFileAndGetPath
:According to your code, when
plplatform === 'win32'
, it will run the/res/pc.ps1
file withPowerShell
. And in the filepc.ps1
, the output is exactly the input, without any modification.After some search I found this article, which says
And that's the problem, Chinese letters(and also letters in many other languages) can't be represented in ASCII encoding, so the
data.toString()
in following code can't get the correctimagePath
.AFAIK there's two way to fix the problem:
imagePath
in filepc.ps1
, the code can be rewritten like this:pc.ps1
to UTF-8, which can represent many letters in various language.Thanks for your work!