Created
May 17, 2021 15:02
-
-
Save airportyh/820777e509d76b0577b23c6276f5253c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <wchar.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
int main() { | |
wchar_t *filename = L"/blah/blah/wimpykid.py"; | |
wchar_t *found = wcsrchr(filename, L'.'); | |
int idx = found - filename; | |
int new_string_size = idx + 8; | |
wchar_t *log_filename = malloc(sizeof(wchar_t) * new_string_size); | |
wcsncpy(log_filename, filename, idx); | |
wcscpy(log_filename + idx, L".rewind"); | |
log_filename[new_string_size - 1] = L'\0'; | |
char *utf8 = malloc(sizeof(char) * new_string_size); | |
wcstombs(utf8, log_filename, new_string_size); | |
// wprintf(L"%d: %ls\n", new_string_size, log_filename); | |
printf("utf8: %s\n", utf8); | |
printf("Hello?\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment