Introspection

Frank fau at riseup.net
Mon Aug 19 08:17:17 UTC 2013


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





More information about the babel-devel mailing list