PoshFunctions icon indicating copy to clipboard operation
PoshFunctions copied to clipboard

Use LiteralPaths for Get-ShortName

Open God-damnit-all opened this issue 4 years ago • 3 comments

Without this, filenames with certain Unicode characters (e.g. [char]0xA789) will erroneously receive the error that the file doesn't exist.

God-damnit-all avatar Jun 13 '21 02:06 God-damnit-all

I've run the function Get-ShortName with a test file that contains ([char]0xA789) as one of the filename characters in both Powershell 5.1 and pwsh 7.1.3 and I have no problems getting the shortname. Could you provide some details?

  1. which version of Powershell you are running
  2. what codepage is the console in? if you don't know run chcp and it will display the codepage
  3. what is the default encoding type running at the console? if you don't know run [Console]::OutputEncoding at a powershell prompt

riedyw avatar Jul 12 '21 17:07 riedyw

I was able to replicate your problem by attempting to enter Alt+A789 from the keyboard and it failed. Something to do with keyboard input handler.

When I attempt the keyboard input from a console running in ConEmu the command runs successfully. Again fingers point to the keyboard handler in the default console application.

riedyw avatar Jul 12 '21 17:07 riedyw

I ran into this issue initially through a script that iterated through tons of files via Get-ChildItem and ForEach-Object. I wish I had saved a snapshot of that script, because it's now changed so much that I'm having trouble replicating it.

It wouldn't hurt to merge this for rare edge cases, it's not like it hurts its functionality in any other way. But it's not as necessary as I first thought. I'm honestly quite frustrated that I can't get the issue to occur anymore, I'm not sure what changed.

God-damnit-all avatar Jul 15 '21 10:07 God-damnit-all