Reputation: 335
Every codepoint in the Unicode standard has a unique English name attached to it. I need translations for these names (for a small subset of codepoints) to languages like German, French, Japanese, ... I do have access to professional translators, so it is of course possible to have those names translated one by one, but the result is not necessarily a good representation of the intention of the Unicode standard. I wonder if the Unicode committee has already made an effort to standardize the codepoint names for languages other than English, so that I could simply refer to their translations? I could not find anything but English on unicode.org, but I still hope I missed something. Thanks in advance!
Upvotes: 6
Views: 330
Reputation: 1976
According to this, there were official French translations for a time, but not anymore.
Upvotes: 0
Reputation: 30123
.NET
/ PowerShell example: [Microsofts.CharMap.UName]::Get('č')
Windows OS: there are localized Unicode properties (name
, at least) saved in localized library getuname.dll
. Use the following script directly, or get inspiration there:
<#
Origin by: http://poshcode.org/5234
Improved by: https://stackoverflow.com/users/3439404/josefz
Use this like this: "ábč",([char]'x'),0xBF | Get-CharInfo
Activate dot-sourced like this (apply a real path instead of .\):
. .\_get-CharInfo_1.1.ps1
#>
Set-StrictMode -Version latest
Add-Type -Name UName -Namespace Microsofts.CharMap -MemberDefinition $(
switch ("$([System.Environment]::SystemDirectory -replace
'\\', '\\')\\getuname.dll") {
{Test-Path -LiteralPath $_ -PathType Leaf} {@"
[DllImport("${_}", ExactSpelling=true, SetLastError=true)]
private static extern int GetUName(ushort wCharCode,
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder buf);
public static string Get(char ch) {
var sb = new System.Text.StringBuilder(300);
UName.GetUName(ch, sb);
return sb.ToString();
}
"@
}
default {'public static string Get(char ch) { return "???"; }'}
})
function Get-CharInfo {
[CmdletBinding()]
[OutputType([System.Management.Automation.PSCustomObject],[System.Array])]
param(
[Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true)]
$InputObject
)
begin {
function out {
param(
[Parameter(Position=0, Mandatory=$true )] $ch,
[Parameter(Position=1, Mandatory=$false)]$nil=''
)
if (0 -le $ch -and 0xFFFF -ge $ch) {
[pscustomobject]@{
Char = [char]$ch
CodePoint = 'U+{0:X4}' -f $ch
Category = [System.Globalization.CharUnicodeInfo]::GetUnicodeCategory($ch)
Description = [Microsofts.CharMap.UName]::Get($ch)
}
} elseif (0 -le $ch -and 0x10FFFF -ge $ch) {
$s = [char]::ConvertFromUtf32($ch)
[pscustomobject]@{
Char = $s
CodePoint = 'U+{0:X}' -f $ch
Category = [System.Globalization.CharUnicodeInfo]::GetUnicodeCategory($s, 0)
Description = '???' + $nil
}
} else {
Write-Warning ('Character U+{0:X} is out of range' -f $ch)
}
}
}
process {
if ($PSBoundParameters['Verbose']) {
Write-Warning "InputObject type = $($InputObject.GetType().Name)"}
if ($null -cne ($InputObject -as [char])) {
#Write-Verbose "A $([char]$InputObject) InputObject character"
out $([int][char]$InputObject) ''
} elseif ($InputObject -isnot [string] -and $null -cne ($InputObject -as [int])) {
#Write-Verbose "B $InputObject InputObject"
out $([int]$InputObject) ''
} else {
$InputObject = [string]$InputObject
#Write-Verbose "C $InputObject InputObject.Length $($InputObject.Length)"
for ($i = 0; $i -lt $InputObject.Length; ++$i) {
if ( [char]::IsHighSurrogate($InputObject[$i]) -and
(1+$i) -lt $InputObject.Length -and
[char]::IsLowSurrogate($InputObject[$i+1])) {
$aux = ' 0x{0:x4},0x{1:x4}' -f [int]$InputObject[$i],
[int]$InputObject[$i+1]
Write-Verbose "surrogate pair $aux at position $i"
out $([char]::ConvertToUtf32($InputObject[$i], $InputObject[1+$i])) $aux
$i++
} else {
out $([int][char]$InputObject[$i]) ''
}
}
}
}
}
Example:
PS D:\PShell> "ábč",([char]'x'),0xBF | Get-CharInfo
Char CodePoint Category Description
---- --------- -------- -----------
á U+00E1 LowercaseLetter Latin Small Letter A With Acute
b U+0062 LowercaseLetter Latin Small Letter B
č U+010D LowercaseLetter Latin Small Letter C With Caron
x U+0078 LowercaseLetter Latin Small Letter X
¿ U+00BF OtherPunctuation Inverted Question Mark
PS D:\PShell> Get-Content .\DataFiles\getcharinfoczech.txt
Char CodePoint Category Description
---- --------- -------- -----------
á U+00E1 LowercaseLetter Malé písmeno latinky a s čárkou nad vpravo
b U+0062 LowercaseLetter Malé písmeno latinky b
č U+010D LowercaseLetter Malé písmeno latinky c s háčkem
x U+0078 LowercaseLetter Malé písmeno latinky x
¿ U+00BF OtherPunctuation Znak obráceného otazníku
PS D:\PShell>
Note that the latter (semi-localized) output comes from the following code (run on the same computer under localized user):
"ábč",([char]'x'),0xBF | Get-CharInfo | Out-File .\DataFiles\getcharinfoczech.txt
Upvotes: 1