[OT] How to check if a file is ASCII or UNICODE
Moderators: Hacker, petermad, Stefan2, white
[OT] How to check if a file is ASCII or UNICODE
I need to check if a file is plain ASCII or UNICODE encoded. There is the WIN32 API function IsTextUnicode which I believe is only working if _UNICODE is defined. But how can I check if _UNICODE is not defined?
Thanks,
tbeu
Thanks,
tbeu
TC plugins: Autodesk 3ds Max / Inventor / Revit Preview, FileInDir, ImageMetaData (JPG Comment/EXIF/IPTC/XMP), MATLAB MAT-file Viewer, Mover, SetFolderDate, Solid Edge Preview, Zip2Zero and more
2tbeu
http://unicode.org/unicode/faq/utf_bom.html#22
In this case I would just check the BOM:I need to check if a file is plain ASCII or UNICODE encoded.
http://unicode.org/unicode/faq/utf_bom.html#22
I got it from here. However, it is said that unicode must be defined, not _UNICODE.Alextp wrote:Where did you see requirement of "_UNICODE"?
TC plugins: Autodesk 3ds Max / Inventor / Revit Preview, FileInDir, ImageMetaData (JPG Comment/EXIF/IPTC/XMP), MATLAB MAT-file Viewer, Mover, SetFolderDate, Solid Edge Preview, Zip2Zero and more
Alex, maybe you can again help me. In fact, I want to rebuild TC's check of text and binary files. ASAIK, TC checks the first 8kiB of a file for characters 0x00 to 0x05. But this way, UNICODE files are detected as text whereas I need to consider them as binary data.
TC plugins: Autodesk 3ds Max / Inventor / Revit Preview, FileInDir, ImageMetaData (JPG Comment/EXIF/IPTC/XMP), MATLAB MAT-file Viewer, Mover, SetFolderDate, Solid Edge Preview, Zip2Zero and more
No, the other way round. I need them as binary data, not as text. Checking for 0x00 to 0x05 always fails, when I open/read the file by fopen/fread/fgetc or CreateFile/ReadFile. Such, UNICODE files are always detected as text which is not what I want.Alextp wrote:You mean they are detected as binary but you need them as text?
TC plugins: Autodesk 3ds Max / Inventor / Revit Preview, FileInDir, ImageMetaData (JPG Comment/EXIF/IPTC/XMP), MATLAB MAT-file Viewer, Mover, SetFolderDate, Solid Edge Preview, Zip2Zero and more