fixed errors in encodeCodepoint