
8 Apr
2015
8 Apr
'15
8:59 p.m.
Hello, I would like to determine the (max) number of bytes a character/units in a certain encoding consumes. Unfortunately there does not seem to be an interface exposed for it (or I just don't see it). I'm doing it this way: (defun max-code-units (encoding) (babel::enc-max-units-per-char (babel::get-character-encoding encoding))) (defun code-unit-size (encoding) (ash (babel::enc-code-unit-size (babel::get-character-encoding encoding)) -3)) (defun max-code-size (encoding) (let ((e (babel::get-character-encoding encoding))) (* (babel::enc-max-units-per-char e) (ash (babel::enc-code-unit-size e) -3)))) Is this a good idea to to that way? Please comment. Thanks, Frank