android long dash in string in code
android, java
Solution
Have you tried unicode notation `\u2014`?
Reference: How to convert a string with Unicode encoding to a string of letters
Problem
I am trying to put a long dash "—" between two words in String in my Android project. For example something like this: ``` Name — Surname ``` The String will be converted in code, not in xml. The only way i found to do this, is converting String to HTML and back. Like this: ``` stringBuilder.append(Name).append(" & mdash; ").append(Surname); Html.fromHtml(stringBuilder.toString()).toString(); ``` (Space between "&" and "mdash;" to prevent convertation on stackoverflow). Can it be done more elegant, without converting to HTML and back? Thanks