Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Sqlite Special characters

I have created an sqlite database and imported data from csv as UTF-8. It shows some unknown characters like . In my android code i have managed this with regular expressions. Now I have problem with \n. My regular expression not detecting \n and it will replace \ and n will be there.

Pattern pattern = Pattern.compile("[^a-zA-Z0-9$' '-:|,&.\"\"()\n]");
Matcher matcher = pattern.matcher(descriptionfromDb);
String description = matcher.replaceAll("");

I have also tried using android Html.fromHtml and Spannable and both are not escaping the symbol and \n not get converted to new line.

like image 927
reji Avatar asked Nov 03 '22 18:11

reji


1 Answers

Try this:

description = description.replaceAll(System.getProperty("line.separator"), "");

For special characters see this answer: How to define special characters in array implementing java Application?

Code for Question mark is ?

like image 197
MAC Avatar answered Nov 11 '22 11:11

MAC