| 93 | } |
| 94 | |
| 95 | const char * |
| 96 | unicode_to_utf8(const WCHAR *unicode_str, char *buf, int buflen) |
| 97 | { |
| 98 | int len = WideCharToMultiByte(CP_UTF8, 0, unicode_str, -1, NULL, 0, NULL, NULL); |
| 99 | |
| 100 | if (len == 0) |
| 101 | return NULL; |
| 102 | |
| 103 | // len includes space for null char |
| 104 | if (len > buflen) |
| 105 | return NULL; |
| 106 | |
| 107 | if (WideCharToMultiByte(CP_UTF8, 0, unicode_str, -1, buf, len, NULL, NULL) == 0) { |
| 108 | return NULL; |
| 109 | } |
| 110 | |
| 111 | return buf; |
| 112 | } |
| 113 | |
| 114 | const char * |
| 115 | unicode_to_utf8(const WCHAR *unicode_str, string& storage) |
no test coverage detected