PowerTip: Display the Character for an ASCII Value

PowerTip: Display the Character for an ASCII Value

  • Comments 11
  • Likes

Summary: Learn a simple trick to display the character associated with an ASCII value.

Hey, Scripting Guy! Question I would like to display the ascii character associated with the ascii value 56. How can I do this?

Hey, Scripting Guy! Answer [char]56

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • <p>Hi, I&#39;m getting e-mails from this list, but they&#39;re not necessarily related to my live account. I would like to unsubscribe, but can&#39;t figure out how. There is no unsubscribe link at the bottom of the e-mail (like you perhaps see in every other list or junk mail you receive). If you can help, please do!</p>

  • <p>@Aaron There is no unsubscribe &nbsp;link because there is no list. If you are getting emails from this blog, it is probably because you have subscribed to the RSS feed (or perhaps someone is spoofing you). You may check your mail client, to see if you are subscribed to the RSS feed, and to tell it to unsubscribe. Hope this helps.</p>

  • <p>Hi Ed,</p> <p>anther variant</p> <p>PS II&gt; [convert]::ToChar(56)</p> <p>with System.Char accelertor you can do this:</p> <p>PS II&gt; [char[]](68,99,57) -split { if([char]::IsLower($_)){$true} else{$false}}</p>

  • <p>Its looking like fun, but microsoft would have seperate stuff for tips and tricks</p>

  • <p>At a PosH prompt:</p> <p>Hold done the &#39;Alt&#39; key and type each of the following numbers on the numeric keypad. After each number relese teh &#39;Alt&#39; key and then key dwn for the next number.</p> <p>[alt-down]72[Alt-Up] etc...</p> <p>72,101,108,108,111,32,87,111,114,108,100,33</p> <p>Yet another way to enter data into PowerShell.</p> <p>For more fun try this sequesnce and watch the screen closely.</p> <p>1,2,3,4,5,6,7,8,9</p> <p>Remember - hold the alt key and type the full number that is between the commas and then relese the alt. &nbsp;hold the alt key for each number.</p> <p>Here is a full chart of the codes.</p> <p><a rel="nofollow" target="_new" href="http://www.alt-codes.net/">http://www.alt-codes.net/</a></p>

  • <p>That&#39;s great for one character, but how do I display a range? &nbsp;Can&#39;t do something like 1..10 | write-host &quot;[char]$_&quot; &nbsp;I know I&#39;m missing something simple.</p>

  • <p>@CherylB</p> <p>for range:</p> <p>PS II&gt; [char[]](65..90)</p>

  • <p>I&#39;ve been doing this since DOS 3.2 I believe - it&#39;s how we built menus and &quot;graphical&quot; screens</p> <p>1. open notepad</p> <p>2. hold down alt key</p> <p>3. ON NUMERIC PAD, type ascii value that you&#39;d like to see the character for - (in your example 56)</p> <p>4. release alt key</p> <p>5. character mapping to ascii(56) will appear - in this case, the number 8</p> <p>NOTE: line draw characters will appear in the 174-223 range as seen below (well hopefully)</p> <p>174,5 «»</p> <p>176,7,8 &nbsp;░▒▓</p> <p>179-100 &nbsp;│┤╡╢╖╕╣║╗╝╜╛┐└─┬├─┼╞╟╚</p> <p>200-223 &nbsp;╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀</p> <p>e</p>

  • <p>Using Ed&#39;s tip as a start, you can easily find the ascii value for any character:</p> <p>[int][char]&#39;8&#39;</p>

  • <p>this does not work in a Write-Host command.</p> <p>I.E. &quot;Write-Host [char]56&quot; Outputs &quot;[char]56&quot; not the ASCII character who&#39;s value is 56.</p> <p>Is the syntax wrong here? I tired variants such as &quot;char[56]&quot; and played with quotes for interloping, no success.</p>

  • <p>@Brandon Ciecko</p> <p>Do this instead: Write-Host ([char]56)</p>