Полное описание Windows Alt+ xкоды
основанный на Кратких деталях по кодам Alt (лучшая статья, которую я видел пока, хотя и неполная).
Для заданных (десятичных) чисел х между 1
и 65535
, Alt - код полученного символ всегда зависит от диапазона ( 1..31
, 32..127
, 128..255
, 256..65535
), и, возможно, но не обязательно зависит от :
- Числовой формат, наличие нуля в начале: Alt+ xпротив Alt+0x
- Приложение Unicode:
- Наследие (код-страницы на основе, не Unicode), например
cmd
,powershell
,notepad
, ... - Юникод, например Wordpad (
write
), Sticky Notes (StikyNot
), окно поиска вexplorer
,…
- Наследие (код-страницы на основе, не Unicode), например
- Язык системы : определяет, какие кодовые страницы ANSI, OEM и MAC и связанные файлы растровых шрифтов используются в качестве параметров по умолчанию для системы.
- Языковой стандарт ввода - пара, состоящая из языка, который пользователь хочет ввести, и метода ввода (здесь сужается до клавиатуры):
- Язык;
- Раскладка клавиатуры.
Диапазон конкретных правил - Alt+x
from to
результат : x-й символ из……
1 31
string ☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼
32 127
… кодовая страница OEM / ANSI (идентичная для всех языковых стандартов в этом диапазоне)
128 255
… кодовая страница OEM по умолчанию для устаревшего языкового стандарта системы : применить вышеуказанные правила к (см. операцию по модулю ) Unicode :… таблица Unicode
256 65535
x % 256
Диапазон конкретных правил - Alt+0x
from to
результат : x-й символ из……
01 031
таблицы Unicode (управляющие символы); check Alt+ 09 символьная табуляция
032 0127
… кодовая страница ANSI / OEM (идентичная для всех локалей в этом диапазоне)
0128 0255
Legacy :… кодовая страница ANSI по умолчанию для раскладки клавиатуры независимо от языка
Unicode :… кодовая страница ANSI по умолчанию для языка независимо от раскладки клавиатуры
0256 065535
Наследие : применяются вышеуказанные правила в x % 256
(включая ведущий ноль)
Unicode :… таблица Unicode (независимо от начального нуля)
Я нашел и дважды проверил ранее описанные правила, используя следующее тестирование входных локалей (см. test_Get-Culture.ps1
Скрипт ниже):
Language L.tag KbdID Keyboard layout -------- ----- -------- --------------- English en-GB 00000809 United Kingdom English en-GB 00000405 Czech Czech cs 00000405 Czech Czech cs 00020409 United States-International Modern Greek el 00000408 Greek Russian ru 00000419 Russian Turkish tr 0000041F Turkish Q Turkish tr 00000426 Latvian Estonian et 0000041B Slovak Estonian et 0001041F Turkish F
Немного непрактичный язык комбинаций раскладки клавиатуры, не так ли? Тем не менее, вышеприведенные правила, похоже, готовы написать их…
Alt KeyCode Finder
param([string[]] $InObject = @([char] 0x0)) Function GetAsciiCode ([char] $gacChar, [int] $gacCode) { if ($gacCode -le 0) { $gacAChar = [byte[]] 0 $gacPInto = [byte[]] 0 $gacPI437 = [byte[]] 0 } else { $gacEUnic = [System.Text.Encoding]::GetEncoding(1200) $gacET437 = [System.Text.Encoding]::GetEncoding(437) $gacETarg = [System.Text.Encoding]::GetEncoding($gacCode) $gacAChar = $gacEUnic.GetBytes($gacChar) $gacPInto = [system.text.encoding]::Convert($gacEUnic,$gacETarg,$gacAChar) $gacPFrom = [system.text.encoding]::Convert($gacETarg,$gacEUnic,$gacPInto) $gacPI437 = [system.text.encoding]::Convert($gacEUnic,$gacET437,$gacAChar) if ( -not ( $gacChar -eq $gacEUnic.GetString($gacPFrom) -or $gacPInto -le 31 )) { $gacPInto = [byte[]] 0 } <# if ($gacChar -eq '§') { Write-Host "abc- " -NoNewline Write-Host $gacCode, AChar, $gacAChar, PInto, $gacPInto, PFrom, $gacPFrom, PI437, $gacPI437 -NoNewline Write-Host " -def" } #> } switch ($gacPInto.Count) { 2 { # double-byte character set (DBCS) recognized [int32] $gacPInNo = $gacPInto[1]+$gacPInto[0]*256 # [int32] $gacPInNo = 0 } 1 { # single-byte character set (SBCS) recognized [int32] $gacPInNo = $gacPInto[0] } default { [int32] $gacPInNo = 0 } } Return @($gacPInNo, $gacPI437[0]) } <# language groups : https://msdn.microsoft.com/en-us/goglobal/bb688174 input method (IME): Get-WinUserLanguageList language examples : https://www.microsoft.com/resources/msdn/goglobal/default.mspx code pages & LCIDs: [System.Globalization.CultureInfo]::GetCultures( [System.Globalization.CultureTypes]::AllCultures)| Format-Custom -Property DisplayName, TextInfo #> $KbdLayouts = @( # Basic Collection (installed on all languages of the OS) @('0409', 437, 1252, 'en-US', 1, 'US & Western Eu'), @('0809', 850, 1252, 'en-GB', 1, 'US & Western Eu'), @('0405', 852, 1250, 'cs-CZ', 2, 'Central Europe'), @('0425', 775, 1257, 'et-EE', 3, 'Baltic'), @('0408', 737, 1253, 'el-GR', 4, 'Greek'), @('0419', 866, 1251, 'ru-RU', 5, 'Cyrillic'), @('041f', 857, 1254, 'tr-TR', 6, 'Turkic'), # East Asian collection: double-byte character sets (DBCS): #@('0411', 0, 932, 'ja-JP', 7, 'Japanese'), # (Japan), DBCS #@('0412', 0, 949, 'ko-KR', 8, 'Korean'), # (Korea), DBCS #@('0404', 0, 950, 'zh-TW', 9, 'Trad. Chinese'),# (Taiwan), DBCS #@('0804', 0, 936, 'zh-CN', 10, 'Simpl.Chinese'),# (China), DBCS # Complex script collection (always installed on Arabic and Hebrew localized OSes) @('041E', 0, 874, 'th-TH', 11, 'Thai'), # (Thailand) @('040D', 862, 1255, 'he-IL', 12, 'Hebrew'), # (Israel) @('0C01', 720, 1256, 'ar-EG', 13, 'Arabic'), # (Egypt) @('042A', 0, 1258, 'vi-VN', 14, 'Vietnamese'), # (Vietnam) # unknown supported code page #@('0445', 0, 0, 'bn-IN', 15, 'Indic'), # Bengali (India) #@('0437', 0, 0, 'ka-GE', 16, 'Georgian'), # (Georgia) #@('042B', 0, 0, 'hy-AM', 17, 'Armenian'), # (Armenia) @('0000', -1, -1, 'xx-xx', 99, 'dummy entry')) # (last array element - not used) #@(LCID, OEM-CP, ANSI-CP, IMEtxt, GroupNo, GroupTxt) $currentLocale = Get-WinSystemLocale $currentIME = "" -f $currentLocale.KeyboardLayoutId $currentOCP = (Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Nls\CodePage").OEMCP $currentACP = (Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Nls\CodePage").ACP $currentHead = 'IME ' + $currentIME + '/' + $currentLocale.Name + "; CP" + $currentOCP + "; ANSI " + $currentACP $currHeadColor = "Cyan" $currCharColor = "Yellow" # write header $InObject Write-Host $(" " -f ` "Ch", "Unicode", "Alt?", "CP IME", "Alt", "Alt0") -NoNewline Write-Host $(" " -f $currentHead) -ForegroundColor $currHeadColor [string] $sX = '' for ($i = 0; $i -lt $InObject.Length ; $i++) { [char] $sAuX = [char] 0x0 [string] $sInX = $InObject[$i] if ($sInX -eq '') { [string] $sInX = [char] 0x00 } Try { [int] 0 + $sInX | Out-Null [char] $sAuX = $sInX | Invoke-Expression } Catch { [string] $sAuX = ''} #Finally {#$sInX += $sAuX } if ($sAuX -eq '') { $sX += $sInX } else { $sX += $sAuX } } for ($i = 0; $i -lt $sX.Length ; $i++) { [char] $Ch = $sX.Substring($i,1) $ChInt = [int] $Ch $ChModulo = $ChInt%256 $altPDesc = "…$ChModulo…" Try { # Get-CharInfo module downloadable from http://poshcode.org/5234 # to add it into the current session: use Import-Module cmdlet $Ch | Get-CharInfo |% { $ChUCode = $_.CodePoint $ChCtgry = $_.Category $ChDescr = $_.Description } } Catch { $ChUCode = "U+" -f $ChInt if ( $ChInt -le 0x1F -or ($ChInt -ge 0x7F -and $ChInt -le 0x9F)) { $ChCtgry = "Control" } else { $ChCtgry = "" } $ChDescr = "" } Finally { $ChOut = $Ch } $altPCode = "$ChInt" # possible Alt+ code $altRCode = "" # effective Alt+ code $altRZero = "" # effective Alt+0 code if ( $ChCtgry -eq "Control" ) { # possibly non-printable character $ChOut = '' $altPCode = "" if ($ChInt -gt 0) { $altRZero = "0$ChInt" } } else { $ChOut = $Ch # supposedly printable character if ($ChInt -le 127) { $altRZero = "0$ChInt" $altRCode = "$ChInt" } } Write-Host "" # for better output readability? Write-Host (" " -f ` $ChOut, $ChUCode, $altPCode, $altPDesc, $altRCode, $altRZero) -NoNewline Write-Host (" " -f $ChDescr) -ForegroundColor $currCharColor $altRCode = "" if ($ChInt -gt 127) { for ($j = 0; $j -le ($KbdLayouts.Length -1) ; $j++) { $altPCode = "" $altRCode = "" $altRZero = "" [int] $ACP = $KbdLayouts[$j][2] # ANSI code page $aaCode = GetAsciiCode $Ch $ACP $xxCode = $aaCode[0] if ($xxCode -eq 0) {} else { $altRZero = "0$xxCode" } [int] $OCP = $KbdLayouts[$j][1] # OEM code page $ooCode = GetAsciiCode $Ch $OCP $yyCode = $ooCode[0] if ($yyCode -eq 0) { } else { $altPCode = "$yyCode" } if (($altPCode + $altRZero) -ne "") { # locale-dependent line $ChOut = "" $ChUCode = "" if ($OCP -le 0) { $altPDesc = '' # not valid OEM CP } else { $altPDesc = ('CP' + [string]$OCP) } $altPDesc += ($KbdLayouts[$j][3].PadLeft(6)) #if ($KbdLayouts[$j][0] -eq $currentIME -or $yyCode -le 128) { if ($OCP -eq [int]$currentOCP -or $yyCode -le 128) { if ($yyCode -eq $ooCode[1]) { $altRCode = $altPCode } } if ($ooCode[1] -ge 1 -and $ooCode[1] -le 31 -and $altRCode -eq "") { $altRCode = $ooCode[1] } if ($ACP -gt 0) { $alt0Desc = '(ANSI' + ([string]$ACP).PadLeft(5) + ') ' + $KbdLayouts[$j][5].PadRight(16) } else { $alt0Desc = '' } if ($OCP -eq [int]$currentOCP -and $altRCode -eq "") { $altRCode = $altPCode } $line = " " -f ` $ChOut, $ChUCode, $altPCode, $altPDesc, $altRCode, $altRZero, $alt0Desc if ($OCP -eq [int]$currentOCP) { Write-Host $line -ForegroundColor $currHeadColor } else { Write-Host $line } } } } } # write footer Write-Host `r`n($InObject -join ",") -ForegroundColor $currCharColor if ($sX -eq '') { # simple help $aux = $MyInvocation.InvocationName "Usage : $aux [<string>]`r`n" "Column : description of character base line" Write-Host " : -description of locale-dependent lines" -NoNewline Write-Host " (coloured for system defaults)" -ForegroundColor $currHeadColor "-------" "Ch : a character itself if printable" "Unicode: character code (Unicode notation)" "Alt? : character code (decimal) = Alt+ code if <=127 or > 255 (unicode apps)" " : -Alt+ code if following CP and IME corresponds to system default OEM-CP" "CP : -OEM code page corresponding to an input method" "IME : …character code modulo 256… (note surrounding ellipses)" " : -keyboard layout (input method) (text)" "Alt : -effective ALT+ code complying with system default OEM-CP request" "Alt0 : -effective ALT+0 code for an IME corresponding to ANSI-CP" Write-Host "IME : Unicode name of a character " -NoNewline Write-Host "(only if activated Get-CharInfo module)" -ForegroundColor $currCharColor " -(ANSI codepage) Laguage group name`r`n" #Write-Host "" }
Не относится к языкам «только Юникод», таким как хинди и грузинский.
Пример вывода : mycharmap 0xfd,ěìμм,291
. Большинство символов выбрано, чтобы показать разные результаты Alt+ 0236в разных локалях ввода.
Приложение 1: mycharmap.bat
скрипт:
@powershell Import-Module D:\PShell\Get-CharInfo_1.1.ps1;D:\PShell\SU\1024763.ps1 %*
Приложение 2: test_Get-Culture.ps1
скрипт:
### test_Get-Culture.ps1 ### " " -f "Language", "L.tag", "KbdID", "Keyboard layout" " " -f "--------", "-----", "--------", "---------------" $gcWULL = Get-WinUserLanguageList $gcWULL | ForEach-Object { $gcU=$_ $gcUIMT=$gcU.InputMethodTips Write-Output $gcUIMT | ForEach-Object { $cLx=$_.Substring(5) $cLz=Get-Item -LiteralPath "HKLM:SYSTEM\CurrentControlSet\Control\Keyboard Layouts\$cLx" $cLy=$cLz.GetValue("Layout Text", $gcU.LanguageTag) " " -f ($gcU.EnglishName).Replace(' (1453-)',''), $gcU.LanguageTag, $cLx, $cLy } }