I'm the groggily user on Github. I tried to use a library named libutf in the past:
https://github.com/holepunchto/libutf/issues/1
https://github.com/holepunchto/libutf/issues/2
The developer was not easy to work with. In the end the thread closed without anything settled.
I still think I was right about wcslen on MinGW-w64.
Hi dimmed,
Could you be more specific as your question is not directly related to Pelles C ?
#include <stdio.h>
#include <wchar.h>
int main(void)
{
const char* str = "\x41\x00\xa9\x03\x03\x26\x2d\x4e\x3d\xd8\x02\xde";
printf("wcslen(str) = %zu\n", wcslen((wchar_t*)str));
return 0;
}
x86
wcslen(str) = 15
x64
wcslen(str) = 9
This version using -Ze gives 6 in both cases
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#include <wchar.h>
#pragma comment(lib, "user32.lib")
int main(void)
{
const char* str = "\x41\x00\xa9\x03\x03\x26\x2d\x4e\x3d\xd8\x02\xde";
printf("wcslen(str) = %zu\n", wcslen((wchar_t*)str));
MessageBoxW(0, (wchar_t*)str, L"test", MB_OK);
return 0;
}
When using:
wcslen((wchar_t*)str))
at the very least, make sure str is a properly terminated wide string (ignoring all other problems with this approach for now).
Append one (or two) '\0' to str, like so:
const char* str = "\x41\x00\xa9\x03\x03\x26\x2d\x4e\x3d\xd8\x02\xde\0";
Hi dimmed,
Any chance to learn why specifically you selected this string?