"Robert Shearman" R.J.Shearman@warwick.ac.uk wrote:
- Add Unicode file detection
+static inline ENCODING PROFILE_DetectTextEncoding(const void * buffer) +{
- if (!memcmp(buffer, bom_utf8, sizeof(bom_utf8)/sizeof(bom_utf8[0])))
return ENCODING_UTF8;
- if (*(WCHAR*)buffer == BOM_UTF16LE)
return ENCODING_UTF16LE;
- if (*(WCHAR*)buffer == BOM_UTF16BE)
return ENCODING_UTF16BE;
- if (*(DWORD*)buffer == BOM_UTF32LE)
return ENCODING_UTF32LE;
- if (*(DWORD*)buffer == BOM_UTF32BE)
return ENCODING_UTF32BE;
- return ENCODING_ANSI;
+}
Why not simply use IsTextUnicode/RtlIsTextUnicode and fix it if necessary?
"Robert Shearman" R.J.Shearman@warwick.ac.uk wrote:
- Add Unicode file detection
+static inline ENCODING PROFILE_DetectTextEncoding(const void * buffer) +{
- if (!memcmp(buffer, bom_utf8,
sizeof(bom_utf8)/sizeof(bom_utf8[0])))
return ENCODING_UTF8;
- if (*(WCHAR*)buffer == BOM_UTF16LE)
return ENCODING_UTF16LE;
- if (*(WCHAR*)buffer == BOM_UTF16BE)
return ENCODING_UTF16BE;
- if (*(DWORD*)buffer == BOM_UTF32LE)
return ENCODING_UTF32LE;
- if (*(DWORD*)buffer == BOM_UTF32BE)
return ENCODING_UTF32BE;
- return ENCODING_ANSI;
+}
Why not simply use IsTextUnicode/RtlIsTextUnicode and fix it if necessary?
Ok, will do. Any idea if it can detect UTF8 as well?
Rob
"Robert Shearman" R.J.Shearman@warwick.ac.uk wrote:
Why not simply use IsTextUnicode/RtlIsTextUnicode and fix it if necessary?
Ok, will do. Any idea if it can detect UTF8 as well?
I don't see that it's documented in MSDN, but probably it's worth to test an actual behaviour under Windows.
"Robert Shearman" R.J.Shearman@warwick.ac.uk wrote:
Why not simply use IsTextUnicode/RtlIsTextUnicode and fix it
if necessary?
Ok, will do. Any idea if it can detect UTF8 as well?
I don't see that it's documented in MSDN, but probably it's worth to test an actual behaviour under Windows.
No, it doesn't detect it. It sets all the flags to 0.
-- Dmitry.
"Robert Shearman" R.J.Shearman@warwick.ac.uk wrote:
Why not simply use IsTextUnicode/RtlIsTextUnicode and fix it
if necessary?
Ok, will do. Any idea if it can detect UTF8 as well?
I don't see that it's documented in MSDN, but probably it's worth to test an actual behaviour under Windows.
No, it doesn't detect it. It sets all the flags to 0.
Then you have to cope with that single case on your own.