[dev] [commits] Horde branch master updated. 6d97c196be61e3bca4413767f7b6f4d12b62fefd
jan at horde.org
Tue Mar 9 10:53:14 UTC 2010
Zitat von Michael M Slusarz <slusarz at horde.org>:
> Quoting Jan Schneider <jan at horde.org>:
>> Zitat von Michael M Slusarz <slusarz at horde.org>:
>>> daf7a5e Added Horde_Util::convertToUtf8().
>> This should be in Horde_String.
> I'm not sure I agree. This function does not necessarily work on
> strings - i.e. you can pass an object to convertToUtf8() and it will
> return an object. All the rest of the Horde_String functions are
> solely related to string data only (they either return string data
> or, for length(), it accepts string data).
This is not true, Horde_String::convertCharset() already converts
objects and arrays too, and it also has a shortcut for converting to
UTF-8 using utf_endcode(). So Horde_Util::convertToUtf8() is really
just a subset of the Horde_String::convertCharset() functionality and
thus duplicating code.
> Truthfully, I'm not sure if there is much use for this function
> outside of Horde_Serialize(). There is certainly no need to use
> Horde_String::convertCharset() in it - utf8_encode() is sufficient
> and using convertCharset() is overkill. The function is quite
> honestly a bit of a hack - essentially in Horde_Serialize it is a
> way to remove non UTF-8 data from a supposed UTF-8 string so that
> json_encode() doesn't die when parsing a string. Ideally, in the
> future, this would be done within json_encode() itself by passing it
> an option value telling it to ignore non UTF-8 characters contained
> in a string.
> I do agree that there is a bunch of other functions in Horde_Util
> that should be moved to Horde_String - things like
> uriB64[Encode|Decode](), strftime2date(), and date2strftime().
Rather to Horde_Url and Horde_Date like you've done that already, thanks!
Do you need professional PHP or Horde consulting?
More information about the dev