in reply to Re^2: UTF-8: Trying to make sense of form input
in thread UTF-8: Trying to make sense of form input
Yes, it can be useful in debugging when the flag matters. In this case, it only served to be a distraction. Thinking in terms of the UTF8 flag is the wrong way to go. Thinking in terms of encoded or not would have avoided all his problems.
- param returns encoded chars.
- decoded_entities accepts decoded chars.
- decoded_entities returns decoded chars.
- print without :encoding accepts encoded chars.
Therefore, he needs to decode what param returns and encode what he prints.
Using is_utf8 gives an idea whether the characters are decoded or not, but it's not reliable. In fact, it's specifically unreliable with decoded_entities since the string decoded_entities returns can have either state for the UTF8 flag. Documentation and Hungarian Notation are better tools here than is_utf8.
Update: Fixed ambiguous pronouns. Fixed bad grammar. Fixed formatting.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: UTF-8: Trying to make sense of form input
by creamygoodness (Curate) on Aug 16, 2009 at 05:41 UTC |