Java can escape html using e.g. Apache CommonsText StringEscapeUtils but it will use html entity names, not numbers. So > becomes > Is there a library or class or some feasible custom approach that will use html entity numbers, so > becomes > and € becomes € etc?
(Context: I'm using a platform where escaped html using entity names is no longer accepted in a certain process for security reasons, so I really need the entity numbers).
There doesn't appear to be.
The Apache Commons Text library maps the values directly to the names.
Apache Commons Text - EntityArrays.java
You can create your own implementation, using the basic set,
",&,<, and>.Input
Output
If you're looking to create an
escapepattern which will encapsulate a much broader range of values, you can implement a range parameter.Note, the ranges here are the allowed code-points, not the to-be-escaped code-points.