Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android long dash in string in code

Tags:

java

android

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

like image 546
Eugene Dudnik Avatar asked Feb 11 '14 13:02

Eugene Dudnik


1 Answers

Have you tried unicode notation \u2014?

Reference: How to convert a string with Unicode encoding to a string of letters

like image 52
vokilam Avatar answered Oct 06 '22 18:10

vokilam