27 Aug
2007
27 Aug
'07
9:14 a.m.
Enrik Berkhan wrote:
The idea would be: try iconv("UTF-8" -> "UTF-8"), escape if that fails.
And escape what, the whole string? It's probably easier just to sanitize the string ourselves, because iconv() may not be available on all platforms.
Is there anonther good portable or even standard way of doing this? Clear disadvantage of iconv() is the non-thread-awareness of the state storage, so it should either be re-allocated on every usage (not cheap, I suppose) or be allocated in thread-local-storage somehow.
Bleah. There's no need to use a function with local non-thread-aware storage. It's easy to know what a valid UTF-8 character is. We should just check ourselves, and escape anything that isn't valid. Alan DeKok.