#---8<---show-chartable.ps1---Jean-JMST-Belgium--- #=10/2006==================================Version 0==========# #=========== Shows chars's table for a codepage===============# # -codepage # defines code page (default is current code page) # -range # defines range of chars (default is 0..255) # -ucat (facultative) # a unicode category to highlight # # ie : # .\show-chartable 850 (60..89) "UpperCaseLetter" # # REMARK # Use a font having Unicode and targetted codepage support. # You can change font in console by doing : # ALT + SPACE, "Properties"/"Font". # ie change to Lucida console or an other one if you have. #======== Tested on PowerShell 1 ===========================# param( [int]$codepage, [array]$range=0..255, $ucat="" ) filter out{$_} function get-codepage{ return [int]((chcp).Split(':')[1].Trim()) } function is-unicodecategory([string]$c){ return [enum]::GetValues([globalization.unicodecategory]) ` -contains $c } $eunprint="`0","`a","`b","`f","`n","`r","`t","`v"` ," ",[string][char]160 $uunprint='`0','`a','`b','`f','`n','`r','`t','`v'` ,'SPC','NBS' for($i=0;$i -lt $eunprint.length;$i++){ $h+=@{$eunprint[$i]=$uunprint[$i]} } if($codepage) { $ocp=get-codepage [void](chcp $codepage) } [string]$add="" if(is-unicodecategory($ucat)) { [string]$add=[enum]::` GetValues([globalization.unicodecategory])` |where{$_ -eq $ucat} } write-host ` ($add+(get-codepage).ToString().PadLeft(88-$add.Length))`n ` -BackgroundColor 'black' ` -ForegroundColor 'green' ` -NoNewLine for($i=0;$i -lt $range.Length;$i++) { write-host $range[$i].ToString("0000") ` -BackgroundColor 'white' ` -ForegroundColor 'darkcyan' ` -NoNewLine write-host ' ' ` -BackgroundColor 'gray' ` -NoNewLine [consolecolor]$fcolor='white' if($eunprint -contains [char]($range[$i])) { write-host ($h[[string]([char]($range[$i]))]).PadLeft(3) ` -BackgroundColor 'darkcyan' ` -ForegroundColor 'blue' ` -NoNewLine } elseif( [Globalization.CharUnicodeInfo]::` GetUnicodeCategory(([string]([char]($range[$i]))|out)) ` -eq $ucat ) { write-host ([string]([char]($range[$i]))).PadLeft(3) ` -BackgroundColor 'darkcyan' ` -ForegroundColor 'green' ` -NoNewLine } else { write-host ([string]([char]($range[$i]))).PadLeft(3) ` -BackgroundColor 'darkcyan' ` -ForegroundColor 'white' ` -NoNewLine } write-host ' ' ` -NoNewLine if(($i+1) % 10 -eq 0){''} } '' [void](chcp $ocp) #---8<---show-chartable.ps1---Jean-JMST-Belgium---