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.

    '; block.insertAdjacentElement('beforebegin', codeheader); let button = codeheader.querySelector('.copy-button'); button.addEventListener("click", async () => { let blockToCopy = block; await copyCode(blockToCopy, button); }); } }); async function copyCode(blockToCopy, button) { let code = blockToCopy.querySelector("code"); let text = ''; if (code) { text = code.innerText; } else { text = blockToCopy.innerText; } try { await navigator.clipboard.writeText(text); } catch (err) { console.error('Failed to copy:', err); } button.innerText = "Copied"; setTimeout(() => { button.innerHTML = '' + svgCodeIcon + ' Copy'; }, 1400); }

    Feedback