On Mon, 25 Feb 2002 20:52:38 +0100 (CET)
Bruno Haible <[EMAIL PROTECTED]> wrote:
> Michael B Allen writes:
>
> > What's the ultimate goal here? Are any of these functions *supposed*
> > to work on multi-byte characters, or will there be mbs* functions?
>
> strcpy strcat strdup
> already work for multi-byte characters
>
> strncpy strncat strncmp
> cannot work for multi-byte characters because they truncate
> characters
>
> strcspn strspn strpbrk strstr
> you can write multibyte aware analogs of these
>
> strchr strrchr
> use a multibyte aware strstr analog instead
>
> Nothing is standardized in this area, but IMO an <mbstring.h> include
> file which defines these for arbitrary encodings, and an <unistring.h>
> which defines these for UTF-8 strings, would be very nice. I'm working
> on an LGPL'ed implementation of the latter.
Ok. This is what I wanted to know.
> > /*
> > * Returns a pointer to the character at off withing the multi-byte string
> ^^^^^^
> Emphasize: at _screen_position_ off.
>
> > * src not examining more than sn bytes.
> > */
> > char *
> > mbsnoff(char *src, int off, size_t sn)
> > {
<snip>
> > while (ucs && (n = mbrtowc(&ucs, src, sn, &ps)) != (size_t)-2) {
>
> Change that to:
>
> while (sn > 0 && (n = mbrtowc(&ucs, src, sn, &ps)) != (size_t)-2) {
Right!
Thanks,
Mike
--
May The Source be with you.
--
Linux-UTF8: i18n of Linux on all levels
Archive: http://mail.nl.linux.org/linux-utf8/