Refactoring of UTF-16 encoding/decoding for further implementation of
encoding/decoding charsets