https://bugs.winehq.org/show_bug.cgi?id=56160
--- Comment #3 from Maotong Zhang zmtong1988@gmail.com --- (In reply to Zeb Figura from comment #2)
What application does this affect?
Wine compiles and generates [win. ini] and [system. ini] using [PROFILE_DetectTextEncoding] to determine that they are also of the [ENCODING_ANSI] type. This does not affect the usage, UTF-8 and ANSI are basically the same and can be parsed. If UTF-16 is used for parsing, there may be issues.
For example: When the program calls GetPrivateProfileSectionNamesW to retrieve the names of all sections in the . ini file (UTF-16 LE), an issue occurs. Function Procedure: [GetPrivateProfileSectionNamesW] -->[PROFILE_Open] -->[PROFILE_Load] -->[PROFILE_DetectTextEncoding]
Result: When executing [PROFILE_DetectTextEncoding], as there is no BOM sequence, it cannot be determined and returns [ENCODING_ANSI]. When calculating [PROFILE_Load], it is correct to use [ENCODING_ANSI] for calculation, which results in the inability to parse the file.
-------------------- static PROFILESECTION *PROFILE_Load(HANDLE hFile, ENCODING * pEncoding) { ...... len = dwFileSize; *pEncoding = PROFILE_DetectTextEncoding(buffer_base, &len); /* len is set to the number of bytes in the character marker. * we want to skip these bytes */ pBuffer = (char *)buffer_base + len; dwFileSize -= len;
switch (*pEncoding) { case ENCODING_ANSI: TRACE("ANSI encoding\n");
len = MultiByteToWideChar(CP_ACP, 0, pBuffer, dwFileSize, NULL, 0); szFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); if (!szFile) { HeapFree(GetProcessHeap(), 0, buffer_base); return NULL; } MultiByteToWideChar(CP_ACP, 0, pBuffer, dwFileSize, szFile, len); szEnd = szFile + len; break; ...... case ENCODING_UTF16LE: TRACE("UTF16 Little Endian encoding\n"); szFile = pBuffer; szEnd = (WCHAR *)((char *)pBuffer + dwFileSize); break; .... }