libmagic support Unicode filename with MinGW

Libmagic or a file is an awesome tools that detect the type of file by its contents not by extension.

You should read it first: Kblog: To compile libmagic with MinGW, and before: Kblog: MinGW: Porting GNU Regex to Windows.

We should make this libmagic as native as possible to windows, so we won’t use Cygwin. But, the Mingw version cannot open the file which contains unicode character. If you feed a buffer to libmagic, there will no problem. But if you tell libmagic to read from a file, the file name string cannot contain unicode character, because the default Win32 API call is the ANSI version, not WIDECHAR version. So, there should be some workaround to solve this problem. YES, it’s simply by conver all corresponding ANSI calls to WIDECHAR calls version.