[Asterisk-Dev] IAX spec: Text formats and character sets

Michael Giagnocavo mgg-digium at atrevido.net
Fri Apr 29 10:12:33 MST 2005


>> The bigger issue is the performance hit this function will cause... if
>> we do it at all, it will have to be compile-time selectable as to
>> whether is uses raw strncpy() or utf8strnpcy().
>
>There should be little performance hit, only loop over a couple of
>characters in the rare case where the string is truncated. In fact I
>would think we would see a big performance gain from using our own
>function instead of strncpy(), since we could use something that only
>copies as many bytes as are in the source string. strncpy() pads the
>destination with zeros, so strncpy(dest, "foo", 100) will copy 100
>bytes, not just the three characters in "foo".

Well, you could just make your own strncpy regardless :).

While the performance hit might not be large and the code for UTF-8 simple,
relative to strncpy, which is a small, very tight, function, the additional
code would be quite large.

-Michael





More information about the asterisk-dev mailing list