#include <File.au3>
#include <winapi.au3>
$filename = "out.txt"
$CODE = _GetFileCode($filename)
MsgBox(0, 0, $CODE)
Func _GetFileCode($file)
Local $nBytes
$tBuffer = DllStructCreate("byte[" & 2 & "]")
$hFile = _WinAPI_CreateFile($file, 2, 2)
_WinAPI_ReadFile($hFile, DllStructGetPtr($tBuffer), 2, $nBytes)
_WinAPI_CloseHandle($hFile)
$sText = DllStructGetData($tBuffer, 1)
Switch $sText
Case "0xEFBB"
Return "UTF-8"
Case "0XFEFF"
Return "Unicode big endian"
Case "0XFEFE"
Return "Unicode"
Case Else
Return "ANSI"
EndSwitch
EndFunc ;==>_GetFileCode
|