New function foreign-encoded-string-octets debian-1.8.1-1 v1.8.1
authorKevin Rosenberg <kevin@rosenberg.net>
Sun, 7 Feb 2010 09:40:03 +0000 (02:40 -0700)
committerKevin Rosenberg <kevin@rosenberg.net>
Sun, 7 Feb 2010 09:40:03 +0000 (02:40 -0700)
ChangeLog
debian/changelog
src/i18n.lisp
src/package.lisp

index 6365fcb04273294d33c7550dc4326e5eea4c19cc..62cc200b4e0b72ab327efc49e18a310792f5ca8d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-02-06 Kevin Rosenberg <kevin@rosenberg.net>
+       * Version 1.8.1
+       * src/i18n.lisp: Add new function foreign-encoded-string-octets
+
 2010-02-06 Kevin Rosenberg <kevin@rosenberg.net>
        * Version 1.8.0
        * src/strings.lisp: Initial support for external-formats with
index 123bfb3a61d599900b52307ec9c60f0c05cae0a0..9e5a2add655cd64390ab779648f4975acfe3835a 100644 (file)
@@ -1,3 +1,9 @@
+cl-uffi (1.8.1-1) unstable; urgency=low
+
+  * New upstream
+
+ -- Kevin M. Rosenberg <kmr@debian.org>  Sun, 07 Feb 2010 02:34:52 -0700
+
 cl-uffi (1.8.0-1) unstable; urgency=low
 
   * New upstream
index 78c04990beced25a3b2542bebdcba0b4c12d6f7b..47a06db565268760cd5e6d3840c4a8683abc4932 100644 (file)
@@ -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))
index 4d3832a65b9e35917dc36945637386885d824fde..15b47928a0b25882f1051e9c0e484e0572156530 100644 (file)
@@ -85,6 +85,7 @@
    #:no-i18n
    #:*default-foreign-encoding*
    #:*foreign-encodings*
+   #:foreign-encoded-string-octets
    ))