7 #include "cAudioDefines.h"
8 #include "cAudioPlatform.h"
9 #include "cAudioMemory.h"
10 #include "cSTLAllocator.h"
15 #ifdef CAUDIO_PLATFORM_WIN
23 #if defined(UNICODE) || defined(_UNICODE)
24 # define _CTEXT(x) L ## x
25 # define cstrcmp wcscmp
26 # define cAudioChar wchar_t
27 # define cfopen(N, M) _wfopen((N).c_str(), L ## M)
30 # define cstrcmp strcmp
31 # define cAudioChar char
32 # define cfopen(N, M) fopen(toUTF8(N), M)
35 #if CAUDIO_REROUTE_STRING_ALLOCATIONS == 1
36 typedef std::basic_string< cAudioChar, std::char_traits<cAudioChar>, cSTLAllocator<cAudioChar> > cAudioString;
38 # if defined(UNICODE) || defined(_UNICODE)
39 typedef std::basic_string<cAudioChar> cAudioString;
41 typedef std::string cAudioString;
46 #if defined(CAUDIO_PLATFORM_WIN)
47 static const char* toUTF8(
const cAudioString& str)
50 static char buffer[8][1024];
53 int buff_size = WideCharToMultiByte(CP_UTF8, 0, str.c_str(), (
int)(str.size() < 1023 ? str.size() : 1023), buffer[
id], 1023, 0,
false);
54 buffer[id][buff_size] = 0;
59 static cAudioString fromUTF8(
const char* str)
61 int str_len = (int)strlen(str);
62 int buf_size = MultiByteToWideChar(CP_UTF8, 0, str, str_len, 0, 0);
63 cAudioString s(buf_size, L
'\0');
64 MultiByteToWideChar(CP_UTF8, 0, str, str_len, &s[0], buf_size);
69 inline const char* toUTF8(
const cAudioString& str)
74 inline cAudioString fromUTF8(
const char* str)
76 return cAudioString(str);