(INC_POSITION): Use CHAR_UNITS_BY_HEAD_UTF16.
(compare): Pay attention to format other than utf-8.
(copy): Delete this function.
(count_by_utf_8, count_by_utf_16, insert): New functions.
(count_utf_16_chars): Fix handling of a surrogate pair.
(find_char_forward, find_char_backward): Likewise.
(mtext__from_data): Delete unnecessary check. Fix number of
allocated bytes.
(mtext_from_data): Don't count items.
(mtext_ref_char): Optimize the code.
(mtext_set_char): Pay attention to format other than utf-8.
(mtext_cat_char): Likewise.
(mtext_dup): Don't call copy, instead do allocation here.
(mtext_cat): Call insert instead of copy.
(mtext_ncat): Likewise.
(mtext_cpy): Delete character at first and call insert instead of
copy.
(mtext_ncpy): Likewise.
(mtext_copy): Likewise.
(mtext_duplicate): Call insert instead of copy.
(mtext_del): Pay attention to format other than utf-8.
(mtext_ins): Simply call insert.
(mtext_ins_char): Pay attention to format other than utf-8.
(mtext_tok): Call insert instead of copy.
(mtext_text): Call UNIT_BYTES.