1

Are there any classes that can take a symbol in a string that is typed in an editText box and replace it with the HTML entity code? Not take the HTML entity code and display the symbol.

For example: if a string is "2∏" is there anything prebuilt that can take it and return "2& #8719;"?

halfer
  • 19,824
  • 17
  • 99
  • 186
ControlAltDelete
  • 3,576
  • 5
  • 32
  • 50

2 Answers2

1

Yes there is ... the TextUtils helper class is included in the Android API

This class has methods for HTML encoding and many other useful functions

return TextUtils.htmlEncode("2∏");

The documentation for this method is htmlEncode

Moog
  • 10,193
  • 2
  • 40
  • 66
  • 1
    Merlin - I thought this would was working fine, but it only seems to encode for the & sign. All other symbols do not get encoded. Any thoughts? – ControlAltDelete Jul 16 '12 at 13:46
0

I ended up using HTML.to (Spanned text).

ControlAltDelete
  • 3,576
  • 5
  • 32
  • 50