View Raw SPL
/* convert Japanese Shift-JIS file to UTF-8 */
utf8jis(fname = "")
{
        local bytes, s;

        if (not(fileexists(fname)))
        {
                error(sprintf("%s - cannot find '%s'", __FUNC__, fname));
        }

        /* read as bytes */
        bytes = readb(fname, ubyte);

        /* convert to utf16 using 932 codepage */
        bytes = charstrsutf16(strchars(bytes), 932);

        /* convert to utf8 string */
        s = strcharsutf16(bytes);

        return(s);
}