Convert character encodings in pure javascript.