MacroPackage: exclToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 9.0
Unrevised from 8.2 to 9.0.
8.2 version


Arguments: ef-name char state-loc &key put-next-octet external-format

ef-name should be a symbol. char should be a character. state-loc should be a place suitable as the first argument to setf. put-next-octet should be a form. external-format should be an external-format object or symbol naming an external-format.

The char-to-octets macro expands to the macro stored in the char-to-octets-macro slot of the external-format named by name. See the description of def-char-to-octets-macro for descriptions of the macro's expansion as well as of the get-next-char, put-next-octet, and external-format arguments.

Users generally do not need to invoke the char-to-octets macro. In most cases, it is more convenient to use string-to-octets.


;; Ensure utf8 conversion macros are available by explicitly loading the
;; external-format definition.  This suppresses the macro removal
;; optimizations that may occur when external-format is autoloaded.
(let ((*modules* (remove "ef-utf8" *modules* :test #'string-equal)))
  (require "ef-utf8"))

(let ((utf8-vector (make-array 10
			       :element-type '(unsigned-byte 8)
			       :initial-element 255))
      (state nil)
      (str "hello"))
  (do ((s 0 (1+ start-s))
       (start-s 0 s)
       (v 0))
      ((>= s (length str)) utf8-vector)
      ;; :utf8-base is (crlf-base-ef :utf8)
      (char-to-octets :utf8-base (prog1 (schar str s) (incf s)) state
		      :put-next-octet (lambda (b)
					 (setf (aref utf8-vector v) b)
					 (incf v)))))

	   ==> #(104 101 108 108 111 255 255 255 255 255)

See iacl.htm for more information on international character support in Allegro CL.

Copyright (c) 1998-2012, Franz Inc. Oakland, CA., USA. All rights reserved.
Documentation for Allegro CL version 9.0. This page was not revised from the 8.2 page.
Created 2012.5.30.

Allegro CL version 9.0
Unrevised from 8.2 to 9.0.
8.2 version