1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-21 11:10:21 +02:00

string->pointer and pointer->string have optional encoding arg

* test-suite/tests/foreign.test ("pointer<->string"): Add test cases.

* libguile/foreign.c (scm_string_to_pointer, scm_pointer_to_string): Add
  optional encoding, and in the pointer->string case, length arguments.

* libguile/foreign.h: Update prototypes of internal functions.
  Shouldn't affect ABI as they are internal.

* doc/ref/api-foreign.texi (Void Pointers and Byte Access): Update
  docs.
This commit is contained in:
Andy Wingo 2011-04-01 13:31:26 +02:00
parent 13a78b0fd7
commit c6b08d2194
4 changed files with 90 additions and 26 deletions

View file

@ -153,7 +153,18 @@
(pass-if "bijection [latin1]"
(with-latin1-locale
(let ((s "Szép jó napot!"))
(string=? s (pointer->string (string->pointer s)))))))
(string=? s (pointer->string (string->pointer s))))))
(pass-if "bijection, utf-8"
(let ((s "hello, world"))
(string=? s (pointer->string (string->pointer s "utf-8")
-1 "utf-8"))))
(pass-if "bijection, utf-8 [latin1]"
(let ((s "Szép jó napot!"))
(string=? s (pointer->string (string->pointer s "utf-8")
-1 "utf-8")))))
(with-test-prefix "pointer->procedure"