dtrebbien/lib_mysqludf_str — pull request #1 by outis (2011-10-11 23:32:02+00:00)
Title: Changes: support NULL & fields in functions; use UTF-8 rather than latin1; new `str_capitalize` function

Here are some changes that are generally useful, though they need review before being incorporated into the main repository:

1. Originally, the various string functions couldn't be used on table columns because the arguments would be NULL when the `xxx_init` functions were called. For example, the query:
SELECT str_ucwords(col) FROM `table`;
would fail with the error message:
str_ucwords requires one non-NULL string argument

By supporting NULL values (functions return NULL when any of the arguments are NULL), the string functions could.

2. The UTF-8 encoding incorporates latin1. By switching to UTF-8, the string functions can be used on columns encoded with either UTF-8 or latin1. The functions still can't be used with other character encodings. A better solution would be to include an optional parameter to specify the encoding.

3. `str_ucfirst` doesn't alter trailing characters. Sometimes, it's useful to force trailing characters to lower case. `str_capitalize` does this.

The first commit also changes the behavior of `str_ucwords` to behave as `str_capitalize` by converting all but the first character in a word to lower case, which is typical behavior for other `ucwords` implementations. An alternative is to leave `str_ucwords` as before and create a `str_capitalizewords` function.

Let me know if any of these changes are of interest to you, and what else needs to be done (if anything) to prepare them for incorporation into the main repository.