Bruno Haible wrote on 2002-02-25 15:16 UTC:
> Michael B Allen writes:
> > Do the str* functions handle strings differently if the locale is
> > different?
> 
> It depends on the functions.
> 
> strcpy strncpy strcat strncat strcmp strncmp strdup strchr strrchr
> strcspn strspn strpbrk strstr strtok: NO

Does the latest version of the man pages use the terms byte or char
versus character correctly here? On the RedHat 7.1 system here, it still
says:

       strchr, strrchr - locate character in string
                                ^^^^^^^^^

whereas what the function actually does is to locale chars or bytes in
strings, but in a multi-byte locale not characters. That's obviously
not helpful for multi-byte beginners.

http://www.cl.cam.ac.uk/~mgk25/volatile/ISO-C-FDIS.1999-04.txt says

       7.21.5.2  The strchr function

       Synopsis

       [#1]

               #include <string.h>
               char *strchr(const char *s, int c);

       Description

       [#2]  The  strchr function locates the first occurrence of c
       (converted to a char) in the string pointed to  by  s.   The
       terminating  null  character is considered to be part of the
       string.

       Returns

       [#3] The strchr function returns a pointer  to  the  located
       character, or a null pointer if the character does not occur
       in the string.

which is also not really a crystal clear formulation of whether strchr
is locale dependent and can spot UTF-8 characters or not. Only the
"(converted to a char)" gives a minor hint here of what goes on, as does
the lack of reference to any locale dependency.

Markus

-- 
Markus G. Kuhn, Computer Laboratory, University of Cambridge, UK
Email: mkuhn at acm.org,  WWW: <http://www.cl.cam.ac.uk/~mgk25/>

--
Linux-UTF8:   i18n of Linux on all levels
Archive:      http://mail.nl.linux.org/linux-utf8/

Reply via email to