Macro | Package: excl | ToC | DocOverview | CGDoc | RelNotes | FAQ | Index | PermutedIndex
| Allegro CL version 10.1 Unrevised from 10.0 to 10.1. 10.0 version

## char-to-octets

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.

### Examples:

    ;; 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-2022, Franz Inc. Lafayette, CA., USA. All rights reserved.
This page was not revised from the 10.0 page.
Created 2019.8.20.

|  | ToC | DocOverview | CGDoc | RelNotes | FAQ | Index | PermutedIndex
| Allegro CL version 10.1 Unrevised from 10.0 to 10.1. 10.0 version