7

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

1 Answer 1

30

Have you tried unicode notation \u2014?

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

Sign up to request clarification or add additional context in comments.

1 Comment

Sorry for such a long answer. Yes, It works, thanks). Now will try to find how to mark that answer is correct)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.