X-Git-Url: http://git.kpe.io/?p=uffi.git;a=blobdiff_plain;f=src%2Fi18n.lisp;h=47a06db565268760cd5e6d3840c4a8683abc4932;hp=78c04990beced25a3b2542bebdcba0b4c12d6f7b;hb=01066b26a984761a2c9372871bba3697984a4456;hpb=2bb9a36070147d6c21e4a99d699ec3563c021a70 diff --git a/src/i18n.lisp b/src/i18n.lisp index 78c0499..47a06db 100644 --- a/src/i18n.lisp +++ b/src/i18n.lisp @@ -57,3 +57,17 @@ encoding.") (defun implementation-foreign-encoding (normalized) (cdr (assoc normalized *foreign-encoding-mapping* :test 'eql))) + +(defun foreign-encoded-string-octets (str &optional foreign-encoding) + "Returns the octets required to represent the string when passed to a ~ +foreign function." + ;; AllegroCL, CCL, and Lispworks give correct value without converting + ;; to external-format. CLISP, like SBCL, requires conversion with external- + ;; format + (length #+(and sbcl sb-unicode) + (sb-ext:string-to-octets + str + :external-format (or foreign-encoding + *default-foreign-encoding* + :utf-8)) + #-(and sbcl sb-unicode) str))