Display 3-byte unicode character in Windows PowerShell

Display 3-byte unicode character in Windows PowerShell

Aside from [Char]::ConvertFromUtf32(), heres a way to calculate the surrogate pair by hand for code points over 2 bytes or 16 bits long (http://www.russellcottrell.com/greek/utilities/surrogatepaircalculator.htm):

$S = 0x1F600
[int]$H = [Math]::Truncate(($S - 0x10000) / 0x400) + 0xD800
[int]$L = ($S - 0x10000) % 0x400 + 0xDC00
[char]$H + [char]$L

😀

Display 3-byte unicode character in Windows PowerShell

Leave a Reply

Your email address will not be published. Required fields are marked *