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
Have you tried unicode notation \u2014
?
Reference: How to convert a string with Unicode encoding to a string of letters
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With