Xyb*_*ICE 2 windows special-characters alt-code character-set character-map
如何使用 Windows 附带的任何标准实用程序(或?命令行语句?)找到特定字形(特殊字符)的Alt KeyCode?
我知道这可能看起来像是Find Alt Code for any Character的副本
然而,正如@Tomáš 在对@Rik 的帖子的评论中所指出的,这并没有向所有字符显示 Alt KeyCode (尤其是一些最有用的字符,即箭头、笑脸......等)
基于Alt 代码的简短细节(我见过的最好的文章,虽然不完整)。
对于和之间的给定(十进制)数x,Alt 代码结果字符始终取决于范围 ( , , , ) 并且可能但不必依赖于:1
65535
1..31
32..127
128..255
256..65535
cmd
, powershell
, notepad
, ...write
)、粘滞便笺 ( StikyNot
)、搜索框 in explorer
、...范围特定规则- Alt+x
from to
结果:第x个字符来自 …
1 31
… 字符串??????•????????????¶§??????????
32 127
… OEM/ANSI 代码页(对于此范围内的所有语言环境都相同)
128 255
……系统语言环境的OEM 代码页默认值
256 65535
传统:将上述规则应用于x % 256
(请参阅模运算)
Unicode : … Unicode 表
范围特定规则- Alt+0x
from to
结果:来自…… Unicode 表的第x个字符
01 031
(控制字符);check Alt+ 09 Character Tabulation
032 0127
... ANSI/OEM 代码页(对于此范围内的所有语言环境相同)
0128 0255
Legacy : ...键盘布局 的ANSI 代码页默认值与语言无关Unicode : ...语言的ANSI 代码页默认值与键盘布局无关遗留:应用上述规则to (包括前导零)Unicode : ... Unicode 表(无论前导零如何)
0256 065535
x % 256
无论您的任何语言设置如何,此方法都有效,但键入起来最麻烦:
- 按住Alt键。
- 按+(数字小键盘上的加号键)。
- 输入十六进制 unicode 值。
- 松开Alt钥匙。
唉,这似乎需要以下注册表设置:
reg query "HKEY_Current_User\Control Panel\Input Method" -v EnableHexNumpad
Run Code Online (Sandbox Code Playgroud)
Run Code Online (Sandbox Code Playgroud)HKEY_CURRENT_USER\Control Panel\Input Method EnableHexNumpad REG_SZ 1
如果您还没有上述注册表设置,则从打开的cmd
提示或运行对话框( WinKey+ R) 中使用以下命令:
reg add "HKEY_Current_User\Control Panel\Input Method" -v EnableHexNumpad -t REG_SZ -d "1" -f
Run Code Online (Sandbox Code Playgroud)
我使用下一个测试输入语言环境找到并仔细检查了先前描述的规则(请参阅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
Run Code Online (Sandbox Code Playgroud)
有点不切实际的语言键盘布局组合,不是吗?然而,高于范围的特定规则似乎已准备好编写脚本……
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 = "{0:x4}" -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 $("{0,2} {1,7} {2,7} {3,12}{4,7}{5,7}" -f `
"Ch", "Unicode", "Alt?", "CP IME", "Alt", "Alt0") -NoNewline
Write-Host $(" {0}" -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+{0:x4}" -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 ("{0,2} {1,7} {2,7} {3,12}{4,7}{5,7}" -f `
$ChOut, $ChUCode, $altPCode, $altPDesc, $altRCode, $altRZero) -NoNewline
Write-Host (" {0}" -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 = "{0,2} {1,7} {2,7} {3,12}{4,7}{5,7} {6}" -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 ""
}
Run Code Online (Sandbox Code Playgroud)
不适用于“仅 Unicode”语言,例如印地语和格鲁吉亚语。
示例输出:mycharmap 0xfd,?ì??,291
。大多数字符选择显示不同的Alt+0236结果在不同的输入语言环境中。
附录1:mycharmap.bat
脚本:
@powershell Import-Module D:\PShell\Get-CharInfo_1.1.ps1;D:\PShell\SU\1024763.ps1 %*
Run Code Online (Sandbox Code Playgroud)
附录2:test_Get-Culture.ps1
脚本:
### test_Get-Culture.ps1 ###
"{0,20} {1,5} {2,8} {3}" -f "Language", "L.tag", "KbdID", "Keyboard layout"
"{0,20} {1,5} {2,8} {3}" -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)
"{0,20} {1,5} {2,8} {3}" -f ($gcU.EnglishName).Replace(' (1453-)',''), $gcU.LanguageTag, $cLx, $cLy
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2181 次 |
最近记录: |