Wednesday 15 July 2015

commonsware cwac - Load HTML Content to android RichEditText -



commonsware cwac - Load HTML Content to android RichEditText -

i'm using cwac-richedit librar in project user write text in , app save user input html content

problem when want show saved content user, displays html content. tried :

spanned description = html.fromhtml(stepcontent); rtxtstepdescription.settext(description);

and looks this

edited: user writes in edittext: app saves content html.tohtml(rtxtstepdescription.geteditabletext())

after that, next time open app app loads: <p dir="rtl"><u>&#1587;&#1604;&#1575;&#1605;</u><br> &#1605;&#1578;&#1606; <i>&#1570;&#1586;&#1605;&#1575;&#1740;&#1588;&#1740;</i> &#1576;&#1585;&#1575;&#1740; <b>&#1587;&#1608;&#1575;&#1604;</b></p>

figured out. these html entities, see 1 convertor online here.

use apache stringescapeutils apache commons lang:

import org.apache.commons.lang.stringescapeutils; ... string withcharacters = stringescapeutils.unescapehtml(yourstring);

javadoc says:

unescapes string containing entity escapes string containing actual unicode characters corresponding escapes. supports html 4.0 entities.

for example, string "&lt;fran&ccedil;ais&gt;" become "<français>"

if entity unrecognized, left alone, , inserted verbatim result string. e.g. "&gt;&zzzz;x" become ">&zzzz;x".

as described in answer here

android commonsware-cwac

No comments:

Post a Comment