(defun lookup-foreign-encoding (normalized)
(cdr (assoc normalized *foreign-encoding-mapping* :test 'eql)))
-(defmacro string-to-octets (str &key (encoding *default-foreign-encoding*))
- "Converts a Lisp string to a vector of octets."
+(defmacro string-to-octets (str &key encoding)
(declare (ignorable encoding))
#-(or allegro lispworks openmcl sbcl)
(map-into (make-array (length str) :element-type '(unsigned-byte 8))
(let ((fe (gensym "FE-"))
(ife (gensym "IFE-"))
(s (gensym "STR-")))
- `(let* ((,fe ,encoding)
+ `(let* ((,fe (or ,encoding *default-foreign-encoding*))
(,ife (when ,fe (lookup-foreign-encoding ,fe)))
(,s ,str))
(values
(let ((fe (gensym "FE-"))
(ife (gensym "IFE-"))
(s (gensym "STR-")))
- `(let* ((,fe ,encoding)
+ `(let* ((,fe (or ,encoding *default-foreign-encoding*))
(,ife (when ,fe (lookup-foreign-encoding ,fe)))
(,s ,str))
(if ,ife
)
-(defmacro octets-to-string (octets &key (encoding *default-foreign-encoding*))
+(defmacro octets-to-string (octets &key encoding)
"Converts a vector of octets to a Lisp string."
(declare (ignorable encoding))
#-(or allegro lispworks openmcl sbcl)
(let ((fe (gensym "FE-"))
(ife (gensym "IFE-"))
(oct (gensym "OCTETS-")))
- `(let* ((,fe ,encoding)
+ `(let* ((,fe (or ,encoding *default-foreign-encoding*))
(,ife (when ,fe (lookup-foreign-encoding ,fe)))
(,oct ,octets))
(values
(let ((fe (gensym "FE-"))
(ife (gensym "IFE-"))
(oct (gensym "OCTETS-")))
- `(let* ((,fe ,encoding)
+ `(let* ((,fe (or ,encoding *default-foreign-encoding*))
(,ife (when ,fe (lookup-foreign-encoding ,fe)))
(,oct ,octets))
(if ,ife
)
-(defun foreign-encoded-octet-count (str &key (encoding *default-foreign-encoding*))
+(defun foreign-encoded-octet-count (str &key encoding)
"Returns the octets required to represent the string when passed to a ~
foreign function."
(declare (ignorable encoding))
;; with external-format
#+(or (and allegro ics) (and sbcl sb-unicode) (and clisp i18n))
- (length (string-to-octets str :encoding encoding))
+ (length (string-to-octets str :encoding
+ (or encoding *default-foreign-encoding*)))
#-(or (and allegro ics) (and sbcl sb-unicode) (and clisp i18n))
(length str)