August 12th, 2016

PowerTip: Identify the numeric value of a custom (dingbat) character using PowerShell

Doctor Scripto
Scripter

Summary: Use PowerShell to determine the value of an Extended ASCII character to reproduce it for later use.

Hey, Scripting Guy! Question I have a really simple question that’s been bugging me. I have a string with a special (Extended ASCII) character that I scraped from some output. I can’t find the ASCII value of it to reproduce it. How can I get the value of this silly “Dingbat”?

Hey, Scripting Guy! Answer In PowerShell, all you need to use is the [int] accelerator to get its numerical value!

For example, if your special character is stored as a single character in a string called $char, you can find the value like this:

[int]$char

For the hexadecimal value, just run the results through the [convert] accelerator as in the following example:

[convert]::tostring([int]$char,16)

The Doctor

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.