hactool icon indicating copy to clipboard operation
hactool copied to clipboard

Hactool fails on user accounts with special characters

Open HelloOO7 opened this issue 6 years ago • 5 comments

The program can't open and just says: Cannot convert "C:\Users\Čeněk" to UTF-16

HelloOO7 avatar Jun 28 '18 11:06 HelloOO7

Got the same problem with the "é" in "Rémi"

Rempa212 avatar Jul 23 '18 08:07 Rempa212

Still happening with latest release with "ý"

pekempy avatar Dec 29 '18 22:12 pekempy

This problem is always present in the version 1.3.2.

shadow2560 avatar Mar 20 '20 23:03 shadow2560

It is because the program assumes that the paths read from %HOME%, %USERPROFILE% etc. are in UTF-8, while normally they are in your system locale. I changed the code to the following in filepath.c, not sure if it doesn't introduce any other bugs:

void os_strcpy(oschar_t *dst, const char *src) {
#ifdef _WIN32
    if (src == NULL) return;
    size_t srcLen = strlen(src);
    int requiredSize = MultiByteToWideChar(CP_ACP,0,src,srcLen,0,0);
    if (requiredSize > MAX_PATH-1) {
        fprintf(stderr, "Failed to convert %s to UTF-16: required size too large!\n", src);
        exit(EXIT_FAILURE);
    }
    int retval = MultiByteToWideChar(CP_ACP,0,src,srcLen,dst,requiredSize);
    if (!retval) {
        fprintf(stderr, "Failed to convert %s to UTF-16!\n", src);
        exit(EXIT_FAILURE);
    }
#else
    strcpy(dst, src);
#endif
}

gyorokpeter avatar Jul 10 '21 20:07 gyorokpeter

it happens to me with the _

ifyum avatar May 14 '23 12:05 ifyum