Android add symbol tm (trademark) to text

How can I place the TM character in a line of text like in HTML

™ 

      

+3


source to share


3 answers


Assuming you cannot use the generated HTML entity

™ 

      

you can use unicode escape



String str = "\u2122";

      

or character literal

String str = "β„’";

      

+4


source


For Android String.xml - use:

™

      

For example:



<string name="company_name">Company &#8482;</string>

      

This will display as:

Company β„’

+3


source


To add any special character, you just need to find the Unicode character. Then you can add it to the line like below:

StringBuilder myString = new StringBuilder();
char myUnicodeChar = '\u2122';
myString.append(myUnicodeChar);

      

Or, as @Elliott suggested, you can just use a literal:

StringBuilder myString = new StringBuilder();
char myUnicodeChar = 'β„’';
myString.append(myUnicodeChar);

      

To find a special character, you can simply specify the character name + "Unicode" in a Google search, or use one of the following links to find it:

+1


source







All Articles