5

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.

mmdemirbas
  • 9,060
  • 5
  • 45
  • 53
reji
  • 171
  • 1
  • 12

1 Answers1

2

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 ?

Community
  • 1
  • 1
MAC
  • 15,799
  • 8
  • 54
  • 95
  • thanks for your help .But it seems not working for me. ? is code for question mark. But the symbol i have posted is not a question mark i think .Its an unknown character – reji Aug 06 '12 at 11:38