- ret = utf8_to_tstr(buf_utf8, bufsize_utf8, &buf_tstr, &bufsize_tstr);
+ /* Ignore UTF-8 BOM. */
+ if (bufsize_utf8 >= 3 && (u8)buf_utf8[0] == 0xef &&
+ (u8)buf_utf8[1] == 0xbb && (u8)buf_utf8[2] == 0xbf)
+ offset_utf8 = 3;
+ else
+ offset_utf8 = 0;
+
+ ret = utf8_to_tstr(buf_utf8 + offset_utf8, bufsize_utf8 - offset_utf8,
+ &buf_tstr, &bufsize_tstr);