When I enter some capital cyrillic letters in PowerShell console, they are not displayed. For instance 'A cyrillic'

Георги Грозданов 0 Reputation points
2023-02-15T14:18:59.1966667+00:00

When I enter some capital Cyrillic letters in Powershell console, they are not displayed.

Only 9 capital letters I'm able to enter when I declare a variable. When I want to type $a = 'A', only $a = '' appears in console.

This i valid for 21 capital Cyrillic letters. Only 'ТЪУШЩСФХЦ' are able to be written.

The situation in ISE is OK. Everything is OK.

[System.Text.Encoding]::Default, $OutputEncoding, [console]::OutputEncoding in ISE producing equal result

IsSingleByte : True

BodyName : koi8-r

EncodingName : Cyrillic (Windows)

HeaderName : windows-1251

WebName : windows-1251

WindowsCodePage : 1251

IsBrowserDisplay : True

IsBrowserSave : True

IsMailNewsDisplay : True

IsMailNewsSave : True

EncoderFallback : System.Text.InternalEncoderBestFitFallback

DecoderFallback : System.Text.InternalDecoderBestFitFallback

IsReadOnly : True

CodePage : 1251

$PSDefaultParameterValues['*:Encoding'] = [System.Text.Encoding]::Default in console no result.

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Rich Matheisen 47,906 Reputation points
    2023-02-15T21:04:21.0966667+00:00

    Perhaps your problem is an incorrect code page? The Windows-1251 character set (https://en.wikipedia.org/wiki/Windows-1251) is different to the Windows KOI8-R character set (https://en.wikipedia.org/wiki/KOI8-R#:~:text=KOI8%20stands%20for%20Kod%20Obmena%20Informatsiey%2C%208%20bit,In%20IBM%2C%20KOI8-R%20is%20assigned%20code%20page%20878.)

    One (1251) encodes the capital "A" as 0xC0, and the other (KOI8-R) uses 0xE1.


  2. Rich Matheisen 47,906 Reputation points
    2023-02-24T23:50:59.92+00:00

    If you run this bit of code, are the characters represented correctly?

    
    # UTF8
    #               Т        А        Ъ        В        Г        Ԍ        И
    [byte[]]$x = 208,162, 208,144, 208,170, 208,146, 208,147, 212,140, 208,152
    [System.Text.Encoding]::UTF8.GetString($x)
    
    

    Or, if you want to use the Unicode code-points:

    write-host $([char]0x0418) # И  U+0418
    write-host $([char]0x0422) # T  U+0422
    
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.