Escape HTML whitespace
Escape white space with %20 in place
def htmlEncode(ch: Array[Char]) = {
var spaces = 0
for (c <- ch) {
if (c == ' ')
spaces += 1
}
val newLength = ch.length + 2 * spaces
ch(newLength) = '\0'
for (i <- ch.length - 1 to 0 by -1) {
if (ch(i) == ' ') {
ch(newLength - 1) = ch(i)
ch(newLength - 2) = ch(i - 1)
ch(newLength - 3) = ch(i - 2)
newLength - 3
} else {
ch(newLength - 1) = ch(i)
newLength - 1
}
}
}