mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:14:37 +02:00
Util (Windows): fix possible errors in Unicode.c
This commit is contained in:
@@ -11,22 +11,12 @@ void ffStrbufSetNWS(FFstrbuf* result, uint32_t length, const wchar_t* source)
|
||||
}
|
||||
|
||||
int size_needed = WideCharToMultiByte(CP_UTF8, 0, source, (int)length, NULL, 0, NULL, NULL);
|
||||
ffStrbufEnsureFree(result, (uint32_t)size_needed);
|
||||
WideCharToMultiByte(CP_UTF8, 0, source, (int)length, result->chars, size_needed, NULL, NULL);
|
||||
result->length = (uint32_t)size_needed;
|
||||
result->chars[size_needed] = '\0';
|
||||
}
|
||||
|
||||
void ffStrbufInitNWS(FFstrbuf* result, uint32_t length, const wchar_t* source)
|
||||
{
|
||||
if(!length)
|
||||
if (size_needed < 0)
|
||||
{
|
||||
ffStrbufInit(result);
|
||||
ffStrbufSetF(result, "WCTMB failed: %u", (unsigned) GetLastError());
|
||||
return;
|
||||
}
|
||||
|
||||
int size_needed = WideCharToMultiByte(CP_UTF8, 0, source, (int)length, NULL, 0, NULL, NULL);
|
||||
ffStrbufInitA(result, (uint32_t)size_needed + 1);
|
||||
ffStrbufEnsureFixedLengthFree(result, (uint32_t)size_needed);
|
||||
WideCharToMultiByte(CP_UTF8, 0, source, (int)length, result->chars, size_needed, NULL, NULL);
|
||||
result->length = (uint32_t)size_needed;
|
||||
result->chars[size_needed] = '\0';
|
||||
|
||||
@@ -11,7 +11,11 @@ static inline void ffStrbufSetWS(FFstrbuf* result, const wchar_t* source)
|
||||
return ffStrbufSetNWS(result, (uint32_t)wcslen(source), source);
|
||||
}
|
||||
|
||||
void ffStrbufInitNWS(FFstrbuf* result, uint32_t length, const wchar_t* source);
|
||||
static inline void ffStrbufInitNWS(FFstrbuf* result, uint32_t length, const wchar_t* source)
|
||||
{
|
||||
ffStrbufInit(result);
|
||||
return ffStrbufSetNWS(result, length, source);
|
||||
}
|
||||
|
||||
static inline void ffStrbufInitWS(FFstrbuf* result, const wchar_t* source)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user