Fixed #2. Added support for htmlDecode function

This commit is contained in:
Shekhar Gulati
2016-05-22 16:04:27 +05:30
parent 8fbdbd4e9e
commit 5158ca6b17
3 changed files with 2264 additions and 0 deletions
+12
View File
@@ -885,6 +885,18 @@ public abstract class Strman {
return append(value.substring(0, length - filler.length()), filler);
}
/**
* Converts all HTML entities to applicable characters.
*
* @param encodedHtml The encoded HTML
* @return The decoded HTML
*/
public static String htmlDecode(final String encodedHtml) {
validate(encodedHtml, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
String[] entities = encodedHtml.split("&\\W+;");
return Arrays.stream(entities).map(e -> HtmlEntities.decodedEntities.get(e)).collect(joining());
}
public static String decode(final String value, final int digits, final int radix) {
validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
return Arrays