I have a simple groovy script where I want to escape a String for XML...
@Grapes(@Grab(group='org.apache.commons', module='commons-lang3',version='3.9'))
import org.apache.commons.lang3.StringEscapeUtils
def value = "[Apple MacBook Pro with Touch Bar - 15.4 & Core i7 - 16 GB RAM - 512 GB SSD]"
StringEscapeUtils.escapeXml11(value.toString())
As per the docs, it looks like this method just needs a String, so why is it giving this exception...
No signature of method: static org.apache.commons.lang3.StringEscapeUtils.escapeXml11() is applicable for argument types: (String) values: [[Apple MacBook Pro with Touch Bar - 15.4 & Core i7 - 16 GB RAM - 512 GB SSD]]
You have a non-printable character in your code:
Offset: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00000000: 53 74 72 69 6E 67 45 73 63 61 70 65 55 74 69 6C StringEscapeUtil
00000010: 73 2E 65 73 63 61 70 65 58 6D 6C 31 31 E2 80 8B s.escapeXml11b..
00000020: 28 76 61 6C 75 65 2E 74 6F 53 74 72 69 6E 67 28 (value.toString(
00000030: 29 29 0A )).
See after the Xml11
?
It works fine with normal characters.