Re: Defacto standard string library



user923005 <dcorbit@xxxxxxxxx> writes:
On Jan 2, 3:31 pm, jameskuyper <jameskuy...@xxxxxxxxxxx> wrote:
user923005 wrote:
On Jan 2, 1:36 pm, Stephen Sprunk <step...@xxxxxxxxxx> wrote:
...
If you only concatenate one valid string to another, it's not an issue.

If that is all you need to do, then use mem* functions and not str*
functions and there will be less trouble.

But then you'll have to search for, or at least keep track of, the
location of the terminating null byte,

If we are only ever concatenating, then this piece of math is rather
trivial.

And strcat() does it.

in order to tell the mem*
functions how much data to move around or compare. What advantages do
you perceive to using the mem* functions rather than the corresponding
str* functions for this purpose?

The str* functions don't work properly and the mem* functions do.

No, the str* functions work just fine.

Actually, I see no advantage in using mem* functions other than
possibly not trying something that I should not be trying.

I would never use standard C library functions to localize when ICU is
available. It's utter insanity.

Ok, ICU might be the greatest thing since sliced bread; perhaps I'll
take a look at it. That doesn't alter the fact that C's str*
functions *can* be used with UTF-8 strings. They don't, of course, do
everything, but what they do, they do correctly (assuming you use them
correctly).

--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.



Relevant Pages

  • [PATCH 1/6] UML - Fix missing KBUILD_BASENAME
    ... get a definition with the by-hand compilation in the main UML Makefile. ... +#define OFFSET(sym, str, mem) \ ...
    (Linux-Kernel)
  • Re: Defacto standard string library
    ... Please give me an example of a situation where you have null terminated strings, ... There is a mem* function that can be used to do what needs to be done (this is NOT the case for most of the str* functions). ... The corresponding str* function does not work correctly when dealing with a UTF-8 string. ...
    (comp.lang.c)
  • Re: strdup()
    ... malloc failures anyway? ... return mem; ... char *xstrdup(const char *str) ...
    (comp.lang.c)
  • Re: Defacto standard string library
    ... If that is all you need to do, then use mem* functions and not str* ... functions and there will be less trouble. ... str* functions for this purpose? ...
    (comp.lang.c)
  • Re: Defacto standard string library
    ... functions and there will be less trouble. ... location of the terminating null byte, ... The str* functions don't work properly and the mem* functions do. ...
    (comp.lang.c)