有口音问题,编辑文本 [英] edit text with accent issue
问题描述
我写一个Android应用程序,我有编辑文本的问题。
当用户添加文本口音(SP:奴斯sommes恩ETE);
该字符串是不正确的。它转换我的口音symbole为UTF-8我猜。
我该如何处理呢?
PS:我的应用程序是一个法国的应用程序,我真的需要使用口音
。我的code:
字符串描述=((的EditText)findViewById(id.description))的getText()的toString()。
Log.i(UTF8,description.toString());
说明= description.replace(\\ n,);
Log.i(UTF8,description.toString());
有不应该是一个问题。字符串重新presentations是UTF-16 [1]在Java /机器人。我试图在Android下code和得到它的工作的罚款。重音e显示正常。
的EditText findViewById =(EditText上)findViewById(R.id.test_text);
findViewById.setText(高等奴斯sommes恩ETE。);
可编辑的文本= findViewById.getText();
Log.d(TAG,text.toString());
您知道,在你的Log.i()code中的第一个参数是标签吗? Log.i()不接受编码类型作为参数。你可以发布什么那些语句打印?
[1] - 的http://文档。 oracle.com/javase/7/docs/api/java/lang/String.html
I'm writing an android application and I have issue with edit text. When the user adds text with accent (sp: "Nous sommes en été"); The string isn't correct. It convert my accent symbole to utf-8 I guess. How can I deal with it ?
ps: my application is a french app and I really need to use accent.
MY CODE :
String description = ((EditText) findViewById(id.description)).getText().toString();
Log.i("UTF8",description.toString());
description = description.replace("\n", "");
Log.i("UTF8",description.toString());
There shouldn't be a problem. String representations are UTF-16 [1] in java / android. I tried the following code on android and got it to work fine. The accented é displays correctly.
EditText findViewById =(EditText) findViewById(R.id.test_text);
findViewById.setText("École. Nous sommes en été");
Editable text = findViewById.getText();
Log.d(TAG, text.toString());
You know that the first parameter in your Log.i() code is a tag right ? Log.i() does not accept encoding type as a parameter. Can you post what those statements print ?
[1] - http://docs.oracle.com/javase/7/docs/api/java/lang/String.html
这篇关于有口音问题,编辑文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!