I agree with Dirk Vroomen. Check $d018 (53272). If bit 1 is set then upper/lower case, if bit 1 is clear then upper/graphic.
LDA $D018
AND #2
BNE upper_lower
;else upper_graphic
Shadow register does not matter if all you want to do is check the video mode.
if is 24 - then is charset at 8192 ...
24 = $18 then charset at $2000... that is not right!! Charset must be at $1000 or $1800 (unless using custom font, in which case changing upper/lower/graphic does not apply).
Are you trying to change the charset in Bitmap mode??? In bitmap mode, the 'charset' points to $2000 but of course it is a bitmap (and not text) so changing upper/lower/graphic does not apply.
Maybe you are trying to change charset in split-screen mode (both bitmap and text)

If that is the case, then shadow register would be important. In that case check $a2c (2604) bit 1. It should have value $14 (20) in upper/graphic mode or value $16 (22) in upper/lower case.
If you are not using standard text mode, then you should say it so people can post accordingly.