I use the following lines of code:
$revTerm = "". strrev($limitAry["term"]);
$revTerm = utf8_encode($revTerm);
The $revTerm contains Norwegian characters as ø æ å. However, it is shown correctly. I need to reverse them before displaying, so I use the first line. When I display them this way, I get an error of bad xml format - used to fill a grid. When I try to use the second line, I don't get an error but the characters are not shown correctly. Could there be any other way to solve that? If it may help, I use jqGrid to fill those data in.
utf8_encode, the string in$limitAry["term"]is encoded with ISO 8859-1, right?utf8_encode. Sincestrrevis written for single-byte encodings, it swaps the order of bytes that were part of single multi-byte characters, effectively turning them into different characters or nonsensical byte sequences.utf8_encode. If$limitAry["term"]were ISO 8859-1 (or any other single-byte character encoding),strrevwould work andutf8_encodewould convert that reversed string to UTF-8 (including incorrect mapping if$limitAry["term"]is not ISO 8859-1). But if$limitAry["term"]already were UTF-8,strrevwould not work properly and usingutf8_encodewouldn’t make any sense as it’s already UTF-8. But none of these scenarios explain the XML error.