This page is part of the web mail archives of SRFI 50 from before July 7th, 2015. The new archives for SRFI 50 contain all messages, not just those from before July 7th, 2015.
On Mon, 5 Jan 2004, Shiro Kawai wrote: >From: Richard Kelsey <kelsey@xxxxxxx> >> SCHEME_EXTRACT_STRING_CONTENTS(scheme_value, index, count, buffer) >> >> which copies 'count' characters starting from 'index' into 'buffer' >> would be better. Presumably this can be done without GCing. > > >(BTW, The semantics of 'index' and 'count' need to be clearified, >w.r.t. the what-is-a-character issue.) I emphatically agree. I'd suggest breaking it into two functions: int SCHEME_SUBSTRING_BYTE_COUNT(scheme_value, index, count) would take a scheme string as scheme_value and two integers index and count. It would start at index in the string (as scheme counted characters) and tell you how many bytes you needed to hold the next <count> characters (again, as scheme counts characters). int SCHEME_EXTRACT_STRING_CONTENTS(scheme_value, index, count, buffer, bufsize) would do the rest of the job, specifying that scheme_value must be a scheme_string, index is the index as scheme counts characters, count is in characters as scheme counts characters, bufsize is a maximum number of bytes to copy into the buffer, and the function returns the actual number of bytes copied into buffer. This should give you some grace with Multibyte character sets, although you'll probably still want to apply some transformations on the C side to compensate for different *kinds* of multibyte character sets. Bear