0

Issue with "á,é,í, ñ

Im having an issue displaying special characters. I was told there was an error in the encoding. Im running the application on the test devices I have, and I mot getting this error. The person getting this error, is testing the app on the same device model, but with a newer firmware version.

I was told "that glyph is the replacement character. you've screwed up your file encoding somewhere. everything should be UTF-8 to preserve sanity." yet, it runs fine on my device.

is there a known fix for this type of problem. thnx!

EDIT- Below is an image of an error I got when I tried to copy the code written by an engineer in china..having never collaborated before like this Im not sure if this is acommon issue which ends up being reflected on the apputf-8 errorenter image description here

user1446988
  • 333
  • 1
  • 6
  • 22
  • where does the text come from? – Jeffrey Blattman Sep 22 '12 at 01:19
  • it resides in the same .java class where the alertDialog gets called. `dialogBuilder.setMessage("Aquí vamos a probar nuestra pronunciación y reconozimiento.");` If the characters are pulled from a "strings.xml" the characters display fine – user1446988 Sep 22 '12 at 01:39

2 Answers2

1

well ... why are you defining strings in your .java file? they need to exist in strings.xml eventually in order to be localized, and regardless, that is the Android way.

if you look at the top of your strings.xml file, you see a line like this,

<?xml version="1.0" encoding="utf-8"?>

that tells whatever consumes this file that the characters are encoded as UTF-8 (obviously). you will find no such line in your .java file. it's going to be encoded as the eclipse default, which depends on your host OS, and is almost certainly not UTF-8. your special characters are lost in the encoding processes when your .java files are saved.

Jeffrey Blattman
  • 22,176
  • 9
  • 79
  • 134
0

Simple solution: Always use strings.xml.

When you load a string out of java code, it may get mangled depending on what the IDE (Eclipse?) thinks the encoding of your .java file should be and what the java compiler thinks.

My Eclipse workspace uses a Windows encoding (CP1252) by default for .java files. You can see the encoding in file properties. It correctly displays UTF-8 for the strings.xml file.

Turbo J
  • 7,563
  • 1
  • 23
  • 43
  • Thanks for the input. The odd thing is the characters displayed fine and still do on my test devices. The problem began when, to appear when the people Im working with in China added some code to my source code. Still not sure if that causing the issue, or its because they are using adiff. firmware. – user1446988 Sep 23 '12 at 01:51