There's an example under
< Similar, but add ASCII value of char under the cursor (like "ga") >
:set statusline=%<%f%h%m%r%=%b\ 0x%B\ \ %l,%c%V\ %P
It's "Emulat[ing] [the] standard status line with 'ruler' set" and "add[ing] ASCII value of char under the cursor."
The relevant items are
b N Value of character under cursor.
B N As above, in hexadecimal.
As Christian Brabandt points out, you can set just the ruler with
rulerformat, which takes similar items. For example,
:set rulerformat=%b\ 0x%B\ %c%V\ %p%%
Note (see vim-help,
"If the statusline is given by 'statusline' ... this option takes precedence over 'ruler' and 'rulerformat'"