diff options
author | Andy Wingo <wingo@pobox.com> | 2011-04-01 13:31:26 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2011-04-01 13:31:26 +0200 |
commit | c6b08d21947b1b33de1e8cd364553112d4015253 (patch) | |
tree | afd04977f493891892d664fb7cc4d0231cde5ecc /doc/ref/api-foreign.texi | |
parent | 13a78b0fd75a4825de0624e47911810fe8a5d150 (diff) | |
download | guile-c6b08d21947b1b33de1e8cd364553112d4015253.tar.gz |
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.
Diffstat (limited to 'doc/ref/api-foreign.texi')
-rw-r--r-- | doc/ref/api-foreign.texi | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/doc/ref/api-foreign.texi b/doc/ref/api-foreign.texi index b5fdd001b..2dd691675 100644 --- a/doc/ref/api-foreign.texi +++ b/doc/ref/api-foreign.texi @@ -626,20 +626,22 @@ Assuming @var{pointer} points to a memory region that holds a pointer, return this pointer. @end deffn -@deffn {Scheme Procedure} string->pointer string +@deffn {Scheme Procedure} string->pointer string [encoding] Return a foreign pointer to a nul-terminated copy of @var{string} in the -current locale encoding. The C string is freed when the returned -foreign pointer becomes unreachable. +given @var{encoding}, defaulting to the current locale encoding. The C +string is freed when the returned foreign pointer becomes unreachable. -This is the Scheme equivalent of @code{scm_to_locale_string}. +This is the Scheme equivalent of @code{scm_to_stringn}. @end deffn -@deffn {Scheme Procedure} pointer->string pointer -Return the string representing the C nul-terminated string -pointed to by @var{pointer}. The C string is assumed to be -in the current locale encoding. +@deffn {Scheme Procedure} pointer->string pointer [length] [encoding] +Return the string representing the C string pointed to by @var{pointer}. +If @var{length} is omitted or @code{-1}, the string is assumed to be +nul-terminated. Otherwise @var{length} is the number of bytes in memory +pointed to by @var{pointer}. The C string is assumed to be in the given +@var{encoding}, defaulting to the current locale encoding. -This is the Scheme equivalent of @code{scm_from_locale_string}. +This is the Scheme equivalent of @code{scm_from_stringn}. @end deffn @cindex wrapped pointer types |