# Output ASCII code as character on terminal in Latex?

If I have a letter/character, I can output its ASCII value using \number and backtick command:

*\typeout{\numbera}
97


What do I do if I have "97", and I want to show "a" in terminal? I have thought of \char - but note that \char typesets, it doesn't output to terminal (removed \char"97 hex usage as per comment):

*\typeout{\char97}
\char 97


What is the right command to use here?

-
\char"97 doesn't give an a even in a document. "91 is a hex-value, you would need either \char"61 or \char91. –  Ulrike Fischer Jun 23 '12 at 14:21
Thanks for the clarification, @UlrikeFischer - cheers! –  sdaau Jun 23 '12 at 14:28

 {\uccodeA=97
\uppercase{\typeout{== A ==}}}


will typeout the character with character code 97

-
Many thanks for that answer, @DavidCarlisle - cheers! –  sdaau Jun 23 '12 at 15:08
not catcode though :-) last time I checked TeX didn't have that many catcodes --- character code –  Frank Mittelbach Jun 23 '12 at 15:19
@FrankMittelbach, fixed thanks:-) –  David Carlisle Jun 23 '12 at 15:24
I have written a small tool called texref which can give quick information about category codes and character information, and maybe other things too in future. If you think it's useful, perhaps consider including it in your answer. github.com/kieranclancy/texref.git –  codebeard Jul 8 '12 at 16:32

If you have hex value rather than the ascii code value then you can use ^^61 to represent a. The hex digits have to be in lowercase (for the letters a-f). If you have only the ascii code number then you have to build your own table (if you want to mix such output with other material) or use the ingenious trick with \uccodeby David, but the latter doesn't really mix well with anything in addition. A simple way to build such a table would be

\makeatletter
\def\asciichar#1{\@nameuse{ascii@\number#1}}
\@namedef{ascii@97}{a}
\@namedef{ascii@98}{b} ... % and all the others
\makeatother


You could add some safety checks to see if the internal command is actually defined etc.

-
Many thanks for posting this answer, @FrankMittelbach - cheers! –  sdaau Jun 23 '12 at 15:21