question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

set-content and get-content's -encoding parameter doesn't tab complete to all options

See original GitHub issue

Steps to reproduce

I think this inhibits discovery.

set-psreadlineoption -editmode emacs
'hi there' | set-content file -encoding #press tab

# for example this works for ebcdic (or ibm037):
'hi there' | set-content file -encoding ebcdic-cp-us

Expected behavior

# many encodings, more than listed by [System.Text.Encoding]::GetEncodings()

Actual behavior

ascii             bigendianutf32    unicode           utf8              utf8NoBOM
bigendianunicode  oem               utf7              utf8BOM           utf32

Environment data

Name                           Value
----                           -----
PSVersion                      7.1.1
PSEdition                      Core
GitCommitId                    7.1.1
OS                             Microsoft Windows 10.0.19042
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jszabo98commented, Mar 12, 2021

A bit of a sidenote, but the displaynames of the encodings in the docs are completely different. Over 30 kinds of ebcdic! https://docs.microsoft.com/en-us/dotnet/api/system.text.encoding?view=net-5.0#list-of-encodings

<div>Encoding Class (System.Text)</div><div>Represents a character encoding. </div>
1reaction
jszabo98commented, Mar 12, 2021

I don’t think this is too horrible if tab shows all options at once. Plus there’s the benefit of knowing this improvement actually exists. It’s like pressing tab after get-childitem in a folder with at least 100 files. It can be limited by typing the first few characters. It will ask first if you want to display all possibilities. (based on https://adamtheautomator.com/powershell-tab-completion/)

function Do-Thing {
    [CmdletBinding()]
    param(
        [Parameter()]
        [string]$Name
    )
    $Name
}

$scriptBlock = { [System.Text.Encoding]::GetEncodings().name }

Register-ArgumentCompleter -CommandName Do-Thing -ParameterName Name -ScriptBlock $scriptBlock


do-thing -name #tab

Display all 138 possibilities? (y or n) _

# 87x35

IBM037                   IBM01146                 x-cp20001                iso-8859-1
IBM437                   IBM01147                 x-Chinese-Eten           iso-8859-2
IBM500                   IBM01148                 x-cp20003                iso-8859-3
ASMO-708                 IBM01149                 x-cp20004                iso-8859-4
DOS-720                  utf-16                   x-cp20005                iso-8859-5
ibm737                   utf-16BE                 x-IA5                    iso-8859-6
ibm775                   windows-1250             x-IA5-German             iso-8859-7
ibm850                   windows-1251             x-IA5-Swedish            iso-8859-8
ibm852                   Windows-1252             x-IA5-Norwegian          iso-8859-9
IBM855                   windows-1253             us-ascii                 iso-8859-13
ibm857                   windows-1254             x-cp20261                iso-8859-15
IBM00858                 windows-1255             x-cp20269                x-Europa
IBM860                   windows-1256             IBM273                   iso-8859-8-i
ibm861                   windows-1257             IBM277                   iso-2022-jp
DOS-862                  windows-1258             IBM278                   csISO2022JP
IBM863                   Johab                    IBM280                   iso-2022-kr
IBM864                   macintosh                IBM284                   x-cp50227
IBM865                   x-mac-japanese           IBM285                   EUC-CN
cp866                    x-mac-chinesetrad        IBM290                   euc-kr
ibm869                   x-mac-korean             IBM297                   hz-gb-2312
IBM870                   x-mac-arabic             IBM420                   GB18030
windows-874              x-mac-hebrew             IBM423                   x-iscii-de
cp875                    x-mac-greek              IBM424                   x-iscii-be
shift_jis                x-mac-cyrillic           x-EBCDIC-KoreanExtended  x-iscii-ta
gb2312                   x-mac-chinesesimp        IBM-Thai                 x-iscii-te
ks_c_5601-1987           x-mac-romanian           koi8-r                   x-iscii-as
big5                     x-mac-ukrainian          IBM871                   x-iscii-or
IBM1026                  x-mac-thai               IBM880                   x-iscii-ka
IBM01047                 x-mac-ce                 IBM905                   x-iscii-ma
IBM01140                 x-mac-icelandic          IBM00924                 x-iscii-gu
IBM01141                 x-mac-turkish            EUC-JP                   x-iscii-pa
IBM01142                 x-mac-croatian           x-cp20936                utf-7
IBM01143                 utf-32                   x-cp20949                utf-8
IBM01144                 utf-32BE                 cp1025
IBM01145                 x-Chinese-CNS            koi8-u
<div> Adam the Automator</div><div>Dynamic Tab Completion with PowerShell ArgumentCompleters</div><div>Learn how to build some handy PowerShell tab-completion parameters that automatically update built by ArgumentCompleters.</div>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Tab autocomplete in Visual Studio Code doesn't work
editor.tabCompletion was off. When I turn it on it toggles between some options (e.g. div/device) but doesn't close tags or complete anything.
Read more >
Set-Content (Microsoft.PowerShell.Management)
The AsByteStream parameter ignores any encoding and the output is written as a stream of bytes. Type: SwitchParameter. Position: Named. Default value: None....
Read more >
How to get bash to stop escaping $ during tab completion?
It looks like in ubuntu 22.04, you need to remove or comment out the completion code at the bottom of ~/bashrc. I then...
Read more >
Fragment | Android Developers
All subclasses of Fragment must include a public no-argument constructor. ... layout that doesn't include the same fragments as the previous layout.
Read more >
Cannot troubleshoot a Web service that's behind a closed ...
When the Web service is behind a closed firewall, the system can't locate whether the error is a network failure or a SM...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found