templates.LoaderUnescapeXML.vm Maven / Gradle / Ivy
private fun unescapeXml(src : String) : String {
var builder : StringBuilder? = null
var i : Int = 0
while (i < src.length) {
val c = src[i]
if(c == '&') {
if(builder == null) {
builder = StringBuilder(src.substring(0,i))
}
if(src[i+1]=='a') {
if(src[i+2] == 'm') {
builder?.append("&")
i = i+5
} else if(src[i+2] == 'p') {
builder?.append("'")
i = i+6
} else {
System.err.println("Could not unescaped chain:" + src[i] + src[i+1] + src[i+2])
}
} else if(src[i+1]=='q') {
builder?.append("\"")
i = i+6
} else if(src[i+1]=='l') {
builder?.append("<")
i = i+4
} else if(src[i+1]=='g') {
builder?.append(">")
i = i+4
} else {
System.err.println("Could not unescaped chain:" + src[i] + src[i+1])
}
} else {
if(builder != null) {
builder?.append(c)
}
i++
}
}
if(builder != null) {
return builder.toString()
} else {
return src
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy