Alexandre Julliard : setupapi: Add support for .inf files in utf-8
format.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Mar 21 08:17:16 CDT 2007
Module: wine
Branch: master
Commit: 31ade1eb67e6b55f1b0c09ef7a806cd53652b1e2
URL: http://source.winehq.org/git/wine.git/?a=commit;h=31ade1eb67e6b55f1b0c09ef7a806cd53652b1e2
Author: Alexandre Julliard <julliard at winehq.org>
Date: Wed Mar 21 13:52:43 2007 +0100
setupapi: Add support for .inf files in utf-8 format.
---
dlls/setupapi/parser.c | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/dlls/setupapi/parser.c b/dlls/setupapi/parser.c
index 3ebb86a..f77b1a1 100644
--- a/dlls/setupapi/parser.c
+++ b/dlls/setupapi/parser.c
@@ -959,10 +959,21 @@ static struct inf_file *parse_file( HANDLE handle, const WCHAR *class, UINT *err
if (!RtlIsTextUnicode( buffer, size, NULL ))
{
- WCHAR *new_buff = HeapAlloc( GetProcessHeap(), 0, size * sizeof(WCHAR) );
- if (new_buff)
+ static const BYTE utf8_bom[3] = { 0xef, 0xbb, 0xbf };
+ WCHAR *new_buff;
+ UINT codepage = CP_ACP;
+ UINT offset = 0;
+
+ if (size > sizeof(utf8_bom) && !memcmp( buffer, utf8_bom, sizeof(utf8_bom) ))
+ {
+ codepage = CP_UTF8;
+ offset = sizeof(utf8_bom);
+ }
+
+ if ((new_buff = HeapAlloc( GetProcessHeap(), 0, size * sizeof(WCHAR) )))
{
- DWORD len = MultiByteToWideChar( CP_ACP, 0, buffer, size, new_buff, size );
+ DWORD len = MultiByteToWideChar( codepage, 0, (char *)buffer + offset,
+ size - offset, new_buff, size );
err = parse_buffer( file, new_buff, new_buff + len, error_line );
HeapFree( GetProcessHeap(), 0, new_buff );
}
More information about the wine-cvs
mailing list