| 76 | } |
| 77 | |
| 78 | char* SU::TCharToCP(const TCHAR * string, int cp) { |
| 79 | int size = 0; |
| 80 | int ret = 0; |
| 81 | |
| 82 | if (string == NULL) |
| 83 | return NULL; |
| 84 | |
| 85 | if (string[0] == 0) { |
| 86 | char * empty = new char[1]; |
| 87 | empty[0] = 0; |
| 88 | return empty; |
| 89 | } |
| 90 | |
| 91 | #ifndef UNICODE |
| 92 | size = ::MultiByteToWideChar(CP_ACP, 0, string, -1, NULL, 0); |
| 93 | if (size == 0) |
| 94 | return NULL; |
| 95 | |
| 96 | wchar_t * wstring = new wchar_t[size]; |
| 97 | ret = ::MultiByteToWideChar(CP_ACP, 0, string, -1, wstring, size); |
| 98 | if (ret == 0) { |
| 99 | delete [] wstring; |
| 100 | return NULL; |
| 101 | } |
| 102 | #else |
| 103 | const wchar_t * wstring = string; |
| 104 | #endif //UNICODE |
| 105 | |
| 106 | size = ::WideCharToMultiByte(cp, 0, wstring, -1, NULL, 0, NULL, NULL); |
| 107 | if (size == 0) { |
| 108 | EXECMBYTE(delete [] wstring;) |
| 109 | return NULL; |
| 110 | } |
| 111 | char * utf8string = new char[size]; |
| 112 | ret = ::WideCharToMultiByte(cp, 0, wstring, -1, utf8string, size, NULL, NULL); |
| 113 | EXECMBYTE(delete [] wstring;) |
| 114 | |
| 115 | if (ret == 0) { |
| 116 | delete [] utf8string; |
| 117 | return NULL; |
| 118 | } |
| 119 | |
| 120 | return utf8string; |
| 121 | } |
| 122 | |
| 123 | TCHAR* SU::DupString(const TCHAR* string) { |
| 124 | if (!string) |
nothing calls this directly
no outgoing calls
no test coverage detected