int __cdecl _open_utf8(const char *path, int oflag, ...) { va_list ap; int pmode = 0; CString strPath = DataToCString(path, -1, DTC_CODE_UTF8); va_start(ap, oflag); pmode = va_arg(ap, int); va_end(ap); return _topen(strPath, oflag, pmode); }
DWORD CM3u::Load(LPCTSTR szFileName) { DWORD dwWin32errorCode = ERROR_SUCCESS; Release(); if (lstrcmpi(getExtName(szFileName), _T(".m3u8")) == 0) { if ((m_encoding != ENC_UTF8N) && (m_encoding != ENC_UTF8B)) { m_encoding = ENC_UTF8N; } } FILE *fp = _tfopen(szFileName, _T("r")); if (fp == NULL) { return ERROR_INVALID_FUNCTION; // QQQ 何かエラーを返しておく } int input_code = DTC_CODE_ANSI; BOOL firstline = TRUE; char buf[1024*64]; char *ptr, *eptr; while (fgets(buf, sizeof(buf), fp)) { ptr = buf; if (firstline) { if (memcmp(buf, "\xEF\xBB\xBF", 3) == 0) { // UTF-8 BOM m_encoding = ENC_UTF8B; ptr += 3; } if ((m_encoding == ENC_UTF8N) || (m_encoding == ENC_UTF8B)) { input_code = DTC_CODE_UTF8; } firstline = FALSE; } eptr = ptr + strlen(ptr); if ((eptr > ptr) && (eptr[-1] == '\n')) { --eptr; } m_strLines.Add(DataToCString(ptr, eptr - ptr, input_code)); //1行追加 } fclose(fp); return dwWin32errorCode; }
FILE *__cdecl fopen_utf8(const char *file, const char *mode) { CString strPath = DataToCString(file, -1, DTC_CODE_UTF8); return _tfopen(strPath, CString(mode)); }
static CString _CnvMetadata(const char *utf8val) { return DataToCString(utf8val, -1, DTC_CODE_UTF8); }