[PATCH 1/2] msvcrt: Detect UTF-8 mode
Detlef Riekenberg
wine.dev at web.de
Fri Aug 24 09:47:58 CDT 2012
This is available since VS2005 and used by vlc:
http://msdn.microsoft.com/en-us/library/yeby3zcb.aspx
http://git.videolan.org/?p=vlc.git;a=blob;f=bin/winvlc.c;h=ff50a003f58b77be90862408476f3dc54c631b23;hb=HEAD#l311
--
By by ... Detlef
---
dlls/msvcrt/file.c | 17 +++++++++++++++--
dlls/msvcrt/msvcrt.h | 3 +++
include/msvcrt/fcntl.h | 29 +++++++++++++++++------------
3 files changed, 35 insertions(+), 14 deletions(-)
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index 59b7eb8..2d0a7d4 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -71,6 +71,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
#define MSVCRT_MAX_FILES 2048
#define MSVCRT_FD_BLOCK_SIZE 32
+static const MSVCRT_wchar_t encoding_utf8[] = {' ','c','c','s','=','U','T','F','-','8'};
+
/* ioinfo structure size is different in msvcrXX.dll's */
typedef struct {
HANDLE handle;
@@ -1271,11 +1273,11 @@ static int msvcrt_get_flags(const MSVCRT_wchar_t* mode, int *open_flags, int* st
{
case 'B': case 'b':
*open_flags |= MSVCRT__O_BINARY;
- *open_flags &= ~MSVCRT__O_TEXT;
+ *open_flags &= ~(MSVCRT__O_TEXT | MSVCRT__O_WTEXT | MSVCRT__O_U16TEXT | MSVCRT__O_U8TEXT);
break;
case 't':
*open_flags |= MSVCRT__O_TEXT;
- *open_flags &= ~MSVCRT__O_BINARY;
+ *open_flags &= ~(MSVCRT__O_BINARY | MSVCRT__O_WTEXT | MSVCRT__O_U16TEXT | MSVCRT__O_U8TEXT);
break;
case 'D':
*open_flags |= MSVCRT__O_TEMPORARY;
@@ -1286,6 +1288,17 @@ static int msvcrt_get_flags(const MSVCRT_wchar_t* mode, int *open_flags, int* st
case '+':
case ' ':
break;
+ case ',':
+ if (!memcmp(mode, encoding_utf8, sizeof(encoding_utf8)) )
+ {
+ *open_flags |= MSVCRT__O_U8TEXT;
+ *open_flags &= ~(MSVCRT__O_TEXT | MSVCRT__O_BINARY | MSVCRT__O_WTEXT | MSVCRT__O_U16TEXT);
+ mode += (sizeof(encoding_utf8)/sizeof(MSVCRT_wchar_t));
+ }
+ else
+ FIXME("mode %s not supported\n", debugstr_w(mode -1));
+
+ break;
default:
FIXME(":unknown flag %c not supported\n",mode[-1]);
}
diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h
index 91dc066..2518640 100644
--- a/dlls/msvcrt/msvcrt.h
+++ b/dlls/msvcrt/msvcrt.h
@@ -749,6 +749,9 @@ struct MSVCRT__stat64 {
#define MSVCRT__O_TEXT 0x4000
#define MSVCRT__O_BINARY 0x8000
#define MSVCRT__O_RAW MSVCRT__O_BINARY
+#define MSVCRT__O_WTEXT 0x10000
+#define MSVCRT__O_U16TEXT 0x20000
+#define MSVCRT__O_U8TEXT 0x40000
/* _statusfp bit flags */
#define MSVCRT__SW_INEXACT 0x00000001 /* inexact (precision) */
diff --git a/include/msvcrt/fcntl.h b/include/msvcrt/fcntl.h
index d0ee97b..efb1039 100644
--- a/include/msvcrt/fcntl.h
+++ b/include/msvcrt/fcntl.h
@@ -14,19 +14,21 @@
#define _O_WRONLY 1
#define _O_RDWR 2
#define _O_ACCMODE (_O_RDONLY|_O_WRONLY|_O_RDWR)
-#define _O_APPEND 0x0008
-#define _O_RANDOM 0x0010
-#define _O_SEQUENTIAL 0x0020
-#define _O_TEMPORARY 0x0040
-#define _O_NOINHERIT 0x0080
-#define _O_CREAT 0x0100
-#define _O_TRUNC 0x0200
-#define _O_EXCL 0x0400
-#define _O_SHORT_LIVED 0x1000
-#define _O_TEXT 0x4000
-#define _O_BINARY 0x8000
+#define _O_APPEND 0x00008
+#define _O_RANDOM 0x00010
+#define _O_SEQUENTIAL 0x00020
+#define _O_TEMPORARY 0x00040
+#define _O_NOINHERIT 0x00080
+#define _O_CREAT 0x00100
+#define _O_TRUNC 0x00200
+#define _O_EXCL 0x00400
+#define _O_SHORT_LIVED 0x01000
+#define _O_TEXT 0x04000
+#define _O_BINARY 0x08000
#define _O_RAW _O_BINARY
-
+#define _O_WTEXT 0x10000
+#define _O_U16TEXT 0x20000
+#define _O_U8TEXT 0x40000
#define O_RDONLY _O_RDONLY
#define O_WRONLY _O_WRONLY
@@ -43,5 +45,8 @@
#define O_TEXT _O_TEXT
#define O_BINARY _O_BINARY
#define O_RAW _O_BINARY
+#define O_WTEXT _O_WTEXT
+#define O_U16TEXT _O_U16TEXT
+#define O_U8TEXT _O_U8TEXT
#endif /* __WINE_FCNTL_H */
--
1.7.5.4
More information about the wine-patches
mailing list