Mike Gran <[email protected]> writes:
> Hi,
>
> The description for scm_to_locale_stringbuf doesn't specify
> what happens when the final multibyte character doesn't fit
> in the provided string buffer.
>
> size_t scm_to_locale_stringbuf (SCM str, char *buf, size_t max_len)
>
> Say the locale is UTF-8, and the last position in BUF would be
> the first byte of a two-byte character. The right thing is not
> to copy that first byte of the character into the last position
> of BUF, but, instead copy a '\0'. But there is no way to indicate
> to the caller that the final '\0' is padding and not a true '\0'.
I'm afraid I don't understand the problem, on two counts.
1. The doc (in the manual) says that scm_to_locale_stringbuf doesn't
add a terminating \0. So presumably any \0s present must be padding.
2. The doc also says that if scm_to_locale_stringbuf's return value
is > max_len (as it would be in your case), the caller should call it
again with a larger buffer.
What is the caller scenario that you have in mind?
Regards,
Neil