ReferenceToken: improve performance of encoding/decoding by using CharBuffers

No need to .subString() anymore in the loop. Just .get() from the CharBuffer.
The string is only wrapped once.