New `toCode` method, without UCS-2.

UCS does not support characters above U+FFFF so we use a custom `toCode`
method.