문제

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

도움이 되었습니까?

해결책

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top