Issue
I am trying to put the characters '<' '>' in a string resource.
If I use the HTML encoding inside the string:
<>
it works in the first build. However, after another build of the project, something automatically converts it to:
&lt;&gt;
So I can't use the previous encoding...
Trying to put "<" or even "\<" in the string will generate an XML error.
Trying to use CDATA will have the same behavior as above.
How do I put a '<' or '>' character with this crap?
UPDATE
I have added the "eclipse" tags, since after some discussion, it seems like an eclipse problem - something automatically edits my XML files. The updated question is - why does eclipse sometimes mess up my strings.xml file and try to encode special characters on its own?
Solution
My current workaround is to use a hard-coded string in my Java class.
String s = "<M>";
mTextView.setText(s);
The other obvious given answer (using CDATA) is theoretically correct, so I'll +1 it, but it fails to work in my Eclipse environment after several build cycles, as Eclipse converts the CDATA section to an encoded string (and then my string displays "CDATA..." in my app).
Since I haven't found a cleaner solution, that's the answer.
Answered By - SirKnigget
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.