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


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):

\char 97

What is the right command to use here?

  • 3
    \char"97 doesn't give an a even in a document. "91 is a hex-value, you would need either \char"61 or \char91. Jun 23, 2012 at 14:21

2 Answers 2

    \uppercase{\typeout{== A ==}}}

will typeout the character with character code 97

  • not catcode though :-) last time I checked TeX didn't have that many catcodes --- character code Jun 23, 2012 at 15:19
  • 1
    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, 2012 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

\@namedef{ascii@98}{b} ... % and all the others

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


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .