# Win32API

Notes on Win32API

## ini file

in Windows 2000(NT3?) Unicode-aware version of WritePrivateProfileStringW()... were implemented.

We can't find any document about character encoding of ini files and mixed use of Unicode/ANSI. We have documented the behavior. In recent versions of Windows (at least Windows 10 and 11), the following behavior is used to support Unicode.

- If the file has a UTF-16LE BOM (0xff 0xfe) at the beginning, the ini file is a Unicode file.
- When reading/writing Unicode/non-Unicode ini files with the ANSI/Unicode API, ACP/Unicode conversion is automatically performed.(This is not done on Windows 9x).

- If the file is a Unicode ini file, it is read/written as Unicode.
- If the file is not a Unicode ini file, it reads and writes as Shift_JIS (ACP) in Japanese environment.
- So possible to use the API transparently regardless of the character encoding of the ini file.
- If Unicode characters that cannot be represented by ACP are written to a non-Unicode ini file, they are replaced by "?" and written to the file.

- When a file is created with the Unicode API, it will not be a Unicode ini file.
- When a file is created with only BOM, it will be a Unicode ini file.