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

Doctor Scripto

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

0 comments

Discussion is closed.

Feedback usabilla icon