Functions for converting between a UTF-8 encoded single-byte character string (char) and a 2-byte wide character string (wchar_t).
#include <locale.h>
#include "wcharconv.h"
int main()
{
char buf[64];
wchar_t wbuf[64];
wchar_to_char(L"Привет, мир! Begrüßung!", buf, sizeof(wbuf));
char_to_wchar(buf, wbuf, sizeof(buf));
setlocale(LC_ALL, ".UTF8");
printf("%s\n", buf);
wprintf(L"%s\n", wbuf);
return 0;
}
Functions | Descriptions |
---|---|
char_to_wchar(const char *from, wchar_t *to, size_t to_size) | Converts a UTF-8 encoded single-byte character string to a 2-byte wide character string. |
wchar_to_char(const wchar_t *from, char *to, size_t to_size) | Converts a 2-byte wide character string to a UTF-8 encoded single-byte character string. |
wcharconv is licensed under the MIT License, see LICENSE.txt for more information.