trunk/src/osd/sdl/strconv.c
| r245272 | r245273 | |
| 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 | | |
| 23 | | CHAR *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 | | |
| 48 | | char *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 | | |
| 73 | | WCHAR *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 | | |
| 92 | | char *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 | | |
| 110 | | int 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 | | |
| 128 | | int 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
| r245272 | r245273 | |
| 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 | | |
| 31 | | CHAR *astring_from_utf8(const char *s); |
| 32 | | char *utf8_from_astring(const CHAR *s); |
| 33 | | |
| 34 | | WCHAR *wstring_from_utf8(const char *s); |
| 35 | | char *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
| r0 | r245273 | |
| 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 | |
| 23 | CHAR *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 | |
| 48 | char *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 | |
| 73 | WCHAR *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 | |
| 92 | char *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 | |
| 110 | int 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 | |
| 128 | int 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
| r0 | r245273 | |
| 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 | |
| 31 | CHAR *astring_from_utf8(const char *s); |
| 32 | char *utf8_from_astring(const CHAR *s); |
| 33 | |
| 34 | WCHAR *wstring_from_utf8(const char *s); |
| 35 | char *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
| r245272 | r245273 | |
| 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 | | |
| 23 | | CHAR *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 | | |
| 48 | | char *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 | | |
| 73 | | WCHAR *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 | | |
| 92 | | char *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 | | |
| 110 | | int 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 | | |
| 128 | | int 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
| r245272 | r245273 | |
| 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 | | |
| 31 | | CHAR *astring_from_utf8(const char *s); |
| 32 | | char *utf8_from_astring(const CHAR *s); |
| 33 | | |
| 34 | | WCHAR *wstring_from_utf8(const char *s); |
| 35 | | char *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__ |