Search code examples
xmlandroid-studioandroid-resourcesmultilingual

How do I resolve specific invalid characters for Khmer character set in Strings.xml?


Been struggling with this specific language translation for an app in Khmer (Cambodian). I have a values-km\strings.xml

I have loaded all my text strings directly in to the xml file, and each element compiles and displays correctly, except for this line:

<string name="text_seesummary">មើលរបាយការណ៍សង្ខេប</string>
        src/main/res/values-km/strings.xml:43:48: Error: An invalid XML
 character (Unicode: 0xb) was found in the element content of the document.

I know that the offending character is a vertical space but I cannot work out how to get Android Studio to compile this. This specific text is used in other UI tools and renders correctly. How can I get Android studio to resolve this string for compilation ? I had found this solution, but it's not applicable as I need to resolve the text at compile time. I am using Android Studio 3.1.3


Solution

  • After some experimentation, I found that the vertical space character (0xb) was inserted by the author. You can delete it from the string via the IDE. It's not obvious, but when you press the delete key at the point where the error is raised, the IDE cursor does not move to reflect the deletion, but the character is actually removed, because it's a non-printable character. Thanks for the tip @kjhughes