mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 09:33:39 +01:00
18 lines
511 B
C
18 lines
511 B
C
#include "unicode.h"
|
|
|
|
void ffWcharToUtf8(const wchar_t* input, FFstrbuf* result)
|
|
{
|
|
int len = (int)wcslen(input);
|
|
if(len <= 0)
|
|
{
|
|
ffStrbufClear(result);
|
|
return;
|
|
}
|
|
|
|
int size_needed = WideCharToMultiByte(CP_UTF8, 0, input, len, NULL, 0, NULL, NULL);
|
|
ffStrbufEnsureFree(result, (uint32_t)size_needed);
|
|
WideCharToMultiByte(CP_UTF8, 0, input, len, result->chars, size_needed, NULL, NULL);
|
|
result->length = (uint32_t)size_needed;
|
|
result->chars[size_needed] = '\0';
|
|
}
|