[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: scm_to_locale_stringbuf
From: |
Neil Jerram |
Subject: |
Re: scm_to_locale_stringbuf |
Date: |
Tue, 03 Feb 2009 22:48:18 +0000 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) |
Mike Gran <address@hidden> 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