Previous 199869 Revisions Next

r36761 Sunday 29th March, 2015 at 07:23:02 UTC by Vasantha Crabb
SDL and Windows strconv are the same thing.
[scripts/src/osd]sdl.lua sdl_cfg.lua windows.lua
[src/osd]strconv.c* strconv.h*
[src/osd/sdl]strconv.c strconv.h
[src/osd/windows]strconv.c strconv.h

trunk/scripts/src/osd/sdl.lua
r245272r245273
125125         MAME_DIR .. "src/osd/modules/debugger/qt/breakpointswindow.c",
126126         MAME_DIR .. "src/osd/modules/debugger/qt/deviceswindow.c",
127127         MAME_DIR .. "src/osd/modules/debugger/qt/deviceinformationwindow.c",
128         
128
129129         GEN_DIR  .. "osd/modules/debugger/qt/debuggerview.moc.c",
130130         GEN_DIR  .. "osd/modules/debugger/qt/windowqt.moc.c",
131131         GEN_DIR  .. "osd/modules/debugger/qt/logwindow.moc.c",
r245272r245273
212212   end
213213
214214   files {
215      MAME_DIR .. "src/osd/sdl/strconv.c",
215      MAME_DIR .. "src/osd/strconv.c",
216216      MAME_DIR .. "src/osd/sdl/sdldir.c",
217217      MAME_DIR .. "src/osd/sdl/sdlfile.c",
218218      MAME_DIR .. "src/osd/sdl/sdlptty_" .. BASE_TARGETOS ..".c",
trunk/scripts/src/osd/sdl_cfg.lua
r245272r245273
66   defines {
77      "OSD_SDL",
88      "SDLMAME_WIN32",
9      "X64_WINDOWS_ABI",
109      "UNICODE",
1110      "_UNICODE",
1211      "SDLMAME_SDL2=1",
trunk/scripts/src/osd/windows.lua
r245272r245273
128128   }
129129
130130   files {
131      MAME_DIR .. "src/osd/strconv.c",
131132      MAME_DIR .. "src/osd/modules/osdmodule.c",
132133      MAME_DIR .. "src/osd/windows/main.c",
133      MAME_DIR .. "src/osd/windows/strconv.c",
134134      MAME_DIR .. "src/osd/windows/windir.c",
135135      MAME_DIR .. "src/osd/windows/winfile.c",
136136      MAME_DIR .. "src/osd/modules/sync/sync_windows.c",
trunk/src/osd/sdl/strconv.c
r245272r245273
1// license:BSD-3-Clause
2// copyright-holders:Aaron Giles
3//============================================================
4//
5//  strconv.c - Win32 string conversion
6//
7//============================================================
8
9#if defined(SDLMAME_WIN32) || defined(OSD_WINDOWS)
10#define WIN32_LEAN_AND_MEAN
11#include <windows.h>
12#endif
13
14// MAMEOS headers
15#include "strconv.h"
16#include "unicode.h"
17
18#if defined(SDLMAME_WIN32) || defined(OSD_WINDOWS)
19//============================================================
20//  astring_from_utf8
21//============================================================
22
23CHAR *astring_from_utf8(const char *utf8string)
24{
25   WCHAR *wstring;
26   int char_count;
27   CHAR *result;
28
29   // convert MAME string (UTF-8) to UTF-16
30   char_count = MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, NULL, 0);
31   wstring = (WCHAR *)alloca(char_count * sizeof(*wstring));
32   MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, wstring, char_count);
33
34   // convert UTF-16 to "ANSI code page" string
35   char_count = WideCharToMultiByte(CP_ACP, 0, wstring, -1, NULL, 0, NULL, NULL);
36   result = (CHAR *)osd_malloc_array(char_count * sizeof(*result));
37   if (result != NULL)
38      WideCharToMultiByte(CP_ACP, 0, wstring, -1, result, char_count, NULL, NULL);
39
40   return result;
41}
42
43
44//============================================================
45//  utf8_from_astring
46//============================================================
47
48char *utf8_from_astring(const CHAR *astring)
49{
50   WCHAR *wstring;
51   int char_count;
52   CHAR *result;
53
54   // convert "ANSI code page" string to UTF-16
55   char_count = MultiByteToWideChar(CP_ACP, 0, astring, -1, NULL, 0);
56   wstring = (WCHAR *)alloca(char_count * sizeof(*wstring));
57   MultiByteToWideChar(CP_ACP, 0, astring, -1, wstring, char_count);
58
59   // convert UTF-16 to MAME string (UTF-8)
60   char_count = WideCharToMultiByte(CP_UTF8, 0, wstring, -1, NULL, 0, NULL, NULL);
61   result = (CHAR *)osd_malloc_array(char_count * sizeof(*result));
62   if (result != NULL)
63      WideCharToMultiByte(CP_UTF8, 0, wstring, -1, result, char_count, NULL, NULL);
64
65   return result;
66}
67
68
69//============================================================
70//  wstring_from_utf8
71//============================================================
72
73WCHAR *wstring_from_utf8(const char *utf8string)
74{
75   int char_count;
76   WCHAR *result;
77
78   // convert MAME string (UTF-8) to UTF-16
79   char_count = MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, NULL, 0);
80   result = (WCHAR *)osd_malloc_array(char_count * sizeof(*result));
81   if (result != NULL)
82      MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, result, char_count);
83
84   return result;
85}
86
87
88//============================================================
89//  utf8_from_wstring
90//============================================================
91
92char *utf8_from_wstring(const WCHAR *wstring)
93{
94   int char_count;
95   char *result;
96
97   // convert UTF-16 to MAME string (UTF-8)
98   char_count = WideCharToMultiByte(CP_UTF8, 0, wstring, -1, NULL, 0, NULL, NULL);
99   result = (char *)osd_malloc_array(char_count * sizeof(*result));
100   if (result != NULL)
101      WideCharToMultiByte(CP_UTF8, 0, wstring, -1, result, char_count, NULL, NULL);
102
103   return result;
104}
105
106//============================================================
107//  osd_uchar_from_osdchar
108//============================================================
109
110int osd_uchar_from_osdchar(UINT32 *uchar, const char *osdchar, size_t count)
111{
112   WCHAR wch;
113
114   count = MIN(count, IsDBCSLeadByte(*osdchar) ? 2 : 1);
115   if (MultiByteToWideChar(CP_ACP, 0, osdchar, (DWORD)count, &wch, 1) != 0)
116      *uchar = wch;
117   else
118      *uchar = 0;
119   return (int) count;
120}
121
122#else
123
124//============================================================
125//  osd_uchar_from_osdchar
126//============================================================
127
128int osd_uchar_from_osdchar(unicode_char *uchar, const char *osdchar, size_t count)
129{
130   wchar_t wch;
131
132   count = mbstowcs(&wch, (char *)osdchar, 1);
133   if (count != -1)
134      *uchar = wch;
135   else
136      *uchar = 0;
137
138   return count;
139}
140
141#endif
trunk/src/osd/sdl/strconv.h
r245272r245273
1// license:BSD-3-Clause
2// copyright-holders:Aaron Giles
3//============================================================
4//
5//  strconv.h - String conversion
6//
7//  Copyright (c) 1996-2007, Nicola Salmoria and the MAME Team.
8//  Visit http://mamedev.org for licensing and usage restrictions.
9//
10//============================================================
11
12#ifndef __OSD_STRCONV__
13#define __OSD_STRCONV__
14
15#include "osdcore.h"
16
17
18
19//============================================================
20//  FUNCTION PROTOTYPES
21//============================================================
22
23#if defined(SDLMAME_WIN32) || defined(OSD_WINDOWS)
24
25#if defined(SDLMAME_WIN32)
26#define WIN32_LEAN_AND_MEAN
27#include <windows.h>
28#endif
29// the result of these functions has to be released with osd_free()
30
31CHAR *astring_from_utf8(const char *s);
32char *utf8_from_astring(const CHAR *s);
33
34WCHAR *wstring_from_utf8(const char *s);
35char *utf8_from_wstring(const WCHAR *s);
36
37#ifdef UNICODE
38#define tstring_from_utf8   wstring_from_utf8
39#define utf8_from_tstring   utf8_from_wstring
40#else // !UNICODE
41#define tstring_from_utf8   astring_from_utf8
42#define utf8_from_tstring   utf8_from_astring
43#endif // UNICODE
44
45#if defined(SDLMAME_WIN32)
46#define _tcsncpy wcsncpy
47#endif
48
49#endif //SDLMAME_WIN32
50
51
52#endif // __OSD_STRCONV__
trunk/src/osd/strconv.c
r0r245273
1// license:BSD-3-Clause
2// copyright-holders:Aaron Giles
3//============================================================
4//
5//  strconv.c - Win32 string conversion
6//
7//============================================================
8
9#if defined(SDLMAME_WIN32) || defined(OSD_WINDOWS)
10#define WIN32_LEAN_AND_MEAN
11#include <windows.h>
12#endif
13
14// MAMEOS headers
15#include "strconv.h"
16#include "unicode.h"
17
18#if defined(SDLMAME_WIN32) || defined(OSD_WINDOWS)
19//============================================================
20//  astring_from_utf8
21//============================================================
22
23CHAR *astring_from_utf8(const char *utf8string)
24{
25   WCHAR *wstring;
26   int char_count;
27   CHAR *result;
28
29   // convert MAME string (UTF-8) to UTF-16
30   char_count = MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, NULL, 0);
31   wstring = (WCHAR *)alloca(char_count * sizeof(*wstring));
32   MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, wstring, char_count);
33
34   // convert UTF-16 to "ANSI code page" string
35   char_count = WideCharToMultiByte(CP_ACP, 0, wstring, -1, NULL, 0, NULL, NULL);
36   result = (CHAR *)osd_malloc_array(char_count * sizeof(*result));
37   if (result != NULL)
38      WideCharToMultiByte(CP_ACP, 0, wstring, -1, result, char_count, NULL, NULL);
39
40   return result;
41}
42
43
44//============================================================
45//  utf8_from_astring
46//============================================================
47
48char *utf8_from_astring(const CHAR *astring)
49{
50   WCHAR *wstring;
51   int char_count;
52   CHAR *result;
53
54   // convert "ANSI code page" string to UTF-16
55   char_count = MultiByteToWideChar(CP_ACP, 0, astring, -1, NULL, 0);
56   wstring = (WCHAR *)alloca(char_count * sizeof(*wstring));
57   MultiByteToWideChar(CP_ACP, 0, astring, -1, wstring, char_count);
58
59   // convert UTF-16 to MAME string (UTF-8)
60   char_count = WideCharToMultiByte(CP_UTF8, 0, wstring, -1, NULL, 0, NULL, NULL);
61   result = (CHAR *)osd_malloc_array(char_count * sizeof(*result));
62   if (result != NULL)
63      WideCharToMultiByte(CP_UTF8, 0, wstring, -1, result, char_count, NULL, NULL);
64
65   return result;
66}
67
68
69//============================================================
70//  wstring_from_utf8
71//============================================================
72
73WCHAR *wstring_from_utf8(const char *utf8string)
74{
75   int char_count;
76   WCHAR *result;
77
78   // convert MAME string (UTF-8) to UTF-16
79   char_count = MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, NULL, 0);
80   result = (WCHAR *)osd_malloc_array(char_count * sizeof(*result));
81   if (result != NULL)
82      MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, result, char_count);
83
84   return result;
85}
86
87
88//============================================================
89//  utf8_from_wstring
90//============================================================
91
92char *utf8_from_wstring(const WCHAR *wstring)
93{
94   int char_count;
95   char *result;
96
97   // convert UTF-16 to MAME string (UTF-8)
98   char_count = WideCharToMultiByte(CP_UTF8, 0, wstring, -1, NULL, 0, NULL, NULL);
99   result = (char *)osd_malloc_array(char_count * sizeof(*result));
100   if (result != NULL)
101      WideCharToMultiByte(CP_UTF8, 0, wstring, -1, result, char_count, NULL, NULL);
102
103   return result;
104}
105
106//============================================================
107//  osd_uchar_from_osdchar
108//============================================================
109
110int osd_uchar_from_osdchar(UINT32 *uchar, const char *osdchar, size_t count)
111{
112   WCHAR wch;
113
114   count = MIN(count, IsDBCSLeadByte(*osdchar) ? 2 : 1);
115   if (MultiByteToWideChar(CP_ACP, 0, osdchar, (DWORD)count, &wch, 1) != 0)
116      *uchar = wch;
117   else
118      *uchar = 0;
119   return (int) count;
120}
121
122#else
123
124//============================================================
125//  osd_uchar_from_osdchar
126//============================================================
127
128int osd_uchar_from_osdchar(unicode_char *uchar, const char *osdchar, size_t count)
129{
130   wchar_t wch;
131
132   count = mbstowcs(&wch, (char *)osdchar, 1);
133   if (count != -1)
134      *uchar = wch;
135   else
136      *uchar = 0;
137
138   return count;
139}
140
141#endif
trunk/src/osd/strconv.h
r0r245273
1// license:BSD-3-Clause
2// copyright-holders:Aaron Giles
3//============================================================
4//
5//  strconv.h - String conversion
6//
7//  Copyright (c) 1996-2007, Nicola Salmoria and the MAME Team.
8//  Visit http://mamedev.org for licensing and usage restrictions.
9//
10//============================================================
11
12#ifndef __OSD_STRCONV__
13#define __OSD_STRCONV__
14
15#include "osdcore.h"
16
17
18
19//============================================================
20//  FUNCTION PROTOTYPES
21//============================================================
22
23#if defined(SDLMAME_WIN32) || defined(OSD_WINDOWS)
24
25#if defined(SDLMAME_WIN32)
26#define WIN32_LEAN_AND_MEAN
27#include <windows.h>
28#endif
29// the result of these functions has to be released with osd_free()
30
31CHAR *astring_from_utf8(const char *s);
32char *utf8_from_astring(const CHAR *s);
33
34WCHAR *wstring_from_utf8(const char *s);
35char *utf8_from_wstring(const WCHAR *s);
36
37#ifdef UNICODE
38#define tstring_from_utf8   wstring_from_utf8
39#define utf8_from_tstring   utf8_from_wstring
40#else // !UNICODE
41#define tstring_from_utf8   astring_from_utf8
42#define utf8_from_tstring   utf8_from_astring
43#endif // UNICODE
44
45#if defined(SDLMAME_WIN32)
46#define _tcsncpy wcsncpy
47#endif
48
49#endif //SDLMAME_WIN32
50
51
52#endif // __OSD_STRCONV__
trunk/src/osd/windows/strconv.c
r245272r245273
1// license:BSD-3-Clause
2// copyright-holders:Aaron Giles
3//============================================================
4//
5//  strconv.c - Win32 string conversion
6//
7//============================================================
8
9#if defined(SDLMAME_WIN32) || defined(OSD_WINDOWS)
10#define WIN32_LEAN_AND_MEAN
11#include <windows.h>
12#endif
13
14// MAMEOS headers
15#include "strconv.h"
16#include "unicode.h"
17
18#if defined(SDLMAME_WIN32) || defined(OSD_WINDOWS)
19//============================================================
20//  astring_from_utf8
21//============================================================
22
23CHAR *astring_from_utf8(const char *utf8string)
24{
25   WCHAR *wstring;
26   int char_count;
27   CHAR *result;
28
29   // convert MAME string (UTF-8) to UTF-16
30   char_count = MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, NULL, 0);
31   wstring = (WCHAR *)alloca(char_count * sizeof(*wstring));
32   MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, wstring, char_count);
33
34   // convert UTF-16 to "ANSI code page" string
35   char_count = WideCharToMultiByte(CP_ACP, 0, wstring, -1, NULL, 0, NULL, NULL);
36   result = (CHAR *)osd_malloc_array(char_count * sizeof(*result));
37   if (result != NULL)
38      WideCharToMultiByte(CP_ACP, 0, wstring, -1, result, char_count, NULL, NULL);
39
40   return result;
41}
42
43
44//============================================================
45//  utf8_from_astring
46//============================================================
47
48char *utf8_from_astring(const CHAR *astring)
49{
50   WCHAR *wstring;
51   int char_count;
52   CHAR *result;
53
54   // convert "ANSI code page" string to UTF-16
55   char_count = MultiByteToWideChar(CP_ACP, 0, astring, -1, NULL, 0);
56   wstring = (WCHAR *)alloca(char_count * sizeof(*wstring));
57   MultiByteToWideChar(CP_ACP, 0, astring, -1, wstring, char_count);
58
59   // convert UTF-16 to MAME string (UTF-8)
60   char_count = WideCharToMultiByte(CP_UTF8, 0, wstring, -1, NULL, 0, NULL, NULL);
61   result = (CHAR *)osd_malloc_array(char_count * sizeof(*result));
62   if (result != NULL)
63      WideCharToMultiByte(CP_UTF8, 0, wstring, -1, result, char_count, NULL, NULL);
64
65   return result;
66}
67
68
69//============================================================
70//  wstring_from_utf8
71//============================================================
72
73WCHAR *wstring_from_utf8(const char *utf8string)
74{
75   int char_count;
76   WCHAR *result;
77
78   // convert MAME string (UTF-8) to UTF-16
79   char_count = MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, NULL, 0);
80   result = (WCHAR *)osd_malloc_array(char_count * sizeof(*result));
81   if (result != NULL)
82      MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, result, char_count);
83
84   return result;
85}
86
87
88//============================================================
89//  utf8_from_wstring
90//============================================================
91
92char *utf8_from_wstring(const WCHAR *wstring)
93{
94   int char_count;
95   char *result;
96
97   // convert UTF-16 to MAME string (UTF-8)
98   char_count = WideCharToMultiByte(CP_UTF8, 0, wstring, -1, NULL, 0, NULL, NULL);
99   result = (char *)osd_malloc_array(char_count * sizeof(*result));
100   if (result != NULL)
101      WideCharToMultiByte(CP_UTF8, 0, wstring, -1, result, char_count, NULL, NULL);
102
103   return result;
104}
105
106//============================================================
107//  osd_uchar_from_osdchar
108//============================================================
109
110int osd_uchar_from_osdchar(UINT32 *uchar, const char *osdchar, size_t count)
111{
112   WCHAR wch;
113
114   count = MIN(count, IsDBCSLeadByte(*osdchar) ? 2 : 1);
115   if (MultiByteToWideChar(CP_ACP, 0, osdchar, (DWORD)count, &wch, 1) != 0)
116      *uchar = wch;
117   else
118      *uchar = 0;
119   return (int) count;
120}
121
122#else
123
124//============================================================
125//  osd_uchar_from_osdchar
126//============================================================
127
128int osd_uchar_from_osdchar(unicode_char *uchar, const char *osdchar, size_t count)
129{
130   wchar_t wch;
131
132   count = mbstowcs(&wch, (char *)osdchar, 1);
133   if (count != -1)
134      *uchar = wch;
135   else
136      *uchar = 0;
137
138   return count;
139}
140
141#endif
trunk/src/osd/windows/strconv.h
r245272r245273
1// license:BSD-3-Clause
2// copyright-holders:Aaron Giles
3//============================================================
4//
5//  strconv.h - String conversion
6//
7//  Copyright (c) 1996-2007, Nicola Salmoria and the MAME Team.
8//  Visit http://mamedev.org for licensing and usage restrictions.
9//
10//============================================================
11
12#ifndef __OSD_STRCONV__
13#define __OSD_STRCONV__
14
15#include "osdcore.h"
16
17
18
19//============================================================
20//  FUNCTION PROTOTYPES
21//============================================================
22
23#if defined(SDLMAME_WIN32) || defined(OSD_WINDOWS)
24
25#if defined(SDLMAME_WIN32)
26#define WIN32_LEAN_AND_MEAN
27#include <windows.h>
28#endif
29// the result of these functions has to be released with osd_free()
30
31CHAR *astring_from_utf8(const char *s);
32char *utf8_from_astring(const CHAR *s);
33
34WCHAR *wstring_from_utf8(const char *s);
35char *utf8_from_wstring(const WCHAR *s);
36
37#ifdef UNICODE
38#define tstring_from_utf8   wstring_from_utf8
39#define utf8_from_tstring   utf8_from_wstring
40#else // !UNICODE
41#define tstring_from_utf8   astring_from_utf8
42#define utf8_from_tstring   utf8_from_astring
43#endif // UNICODE
44
45#if defined(SDLMAME_WIN32)
46#define _tcsncpy wcsncpy
47#endif
48
49#endif //SDLMAME_WIN32
50
51
52#endif // __OSD_STRCONV__


Previous 199869 Revisions Next


© 1997-2024 The MAME Team