From 01066b26a984761a2c9372871bba3697984a4456 Mon Sep 17 00:00:00 2001 From: Kevin Rosenberg Date: Sun, 7 Feb 2010 02:40:03 -0700 Subject: [PATCH] New function foreign-encoded-string-octets --- ChangeLog | 4 ++++ debian/changelog | 6 ++++++ src/i18n.lisp | 14 ++++++++++++++ src/package.lisp | 1 + 4 files changed, 25 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6365fcb..62cc200 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-02-06 Kevin Rosenberg + * Version 1.8.1 + * src/i18n.lisp: Add new function foreign-encoded-string-octets + 2010-02-06 Kevin Rosenberg * Version 1.8.0 * src/strings.lisp: Initial support for external-formats with diff --git a/debian/changelog b/debian/changelog index 123bfb3..9e5a2ad 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +cl-uffi (1.8.1-1) unstable; urgency=low + + * New upstream + + -- Kevin M. Rosenberg Sun, 07 Feb 2010 02:34:52 -0700 + cl-uffi (1.8.0-1) unstable; urgency=low * New upstream 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)) diff --git a/src/package.lisp b/src/package.lisp index 4d3832a..15b4792 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -85,6 +85,7 @@ #:no-i18n #:*default-foreign-encoding* #:*foreign-encodings* + #:foreign-encoded-string-octets )) -- 2.34.1