I have read Microsoft powershell official documentation and i've found this example:
"`u{0048}"
It should display an H
But, i my case, it displays:
u{0048}
I do not need alternatives, i want to understand why it does not work.
Thanks
The `u{XXXX} escape sequence was added to the string expansion grammar in PowerShell 6, and will not be recognized as such in any version of Windows PowerShell.
In Windows PowerShell you can cast the numerical value to [char] in a sub-expression:
"$([char]0x48)"
Or use the -as operator to convert to [char]:
0x48 -as [char]
# or
0x48 -as 'char'
If you're trying to produce the [char] value H without using h, H, [ or ] in the source code, there are plenty of opportunities in PowerShell, ForEach-Object's aliases and member-invocation-via-wildcards is especially handy:
# grab the `h` in `$env:path`
(dir env:pat?).Name.GetEnumerator()|select -Last 1
# reflect against another existing [char] to get the type
$g = 'g'|% ToC?ar ($null)
0x48 -as $g.GetType()
# generate char range between G and I, filter out G and I (pwsh >6.1 only)
'G'..'I'|?{$_-notin'G','I'}
0x48 -as 'char'[char] type or the string char :)