Remove illegal fat32 chars in badge dump
This commit is contained in:
@@ -353,6 +353,7 @@ SetNode * extract_sets(char *badgeMngBuffer, Handle backupDataHandle)
|
||||
DEBUG("Processing icon for set %lu at index %lu\n", cursor->set_id, cursor->set_index);
|
||||
u16 utf16SetName[0x46] = {0};
|
||||
FSFILE_Read(backupDataHandle, NULL, cursor->set_index * 16 * 0x8A, utf16SetName, 0x8A);
|
||||
replace_chars(utf16SetName, ILLEGAL_CHARS, u'-');
|
||||
u16 set_path[256] = {0};
|
||||
struacat(set_path, "/3ds/" APP_TITLE "/BadgeBackups/");
|
||||
size_t set_name_len = strucat(set_path, utf16SetName);
|
||||
@@ -431,6 +432,7 @@ Result extract_badges(void)
|
||||
|
||||
u16 utf16Name[0x46] = {0};
|
||||
FSFILE_Read(backupDataHandle, NULL, 0x35E80 + i * 16 * 0x8A, utf16Name, 0x8A);
|
||||
replace_chars(utf16Name, ILLEGAL_CHARS, u'-');
|
||||
char utf8Name[256] = {0};
|
||||
res = utf16_to_utf8((u8 *) utf8Name, utf16Name, 256);
|
||||
|
||||
@@ -444,6 +446,7 @@ Result extract_badges(void)
|
||||
{
|
||||
u16 utf16SetName[0x46] = {0};
|
||||
FSFILE_Read(backupDataHandle, NULL, set_index * 16 * 0x8A, utf16SetName, 0x8A);
|
||||
replace_chars(utf16SetName, ILLEGAL_CHARS, u'-');
|
||||
char utf8SetName[128] = {0};
|
||||
res = utf16_to_utf8((u8 *) utf8SetName, utf16SetName, 128);
|
||||
if (!res)
|
||||
|
||||
@@ -26,6 +26,17 @@
|
||||
|
||||
#include "unicode.h"
|
||||
|
||||
void replace_chars(u16 *input, char *remove, u16 with)
|
||||
{
|
||||
for (u16 *cursor = input; *cursor != '\0'; cursor++)
|
||||
{
|
||||
if (strchr(remove, (char) (*cursor & 0xFF)))
|
||||
{
|
||||
*cursor = with;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
size_t strulen(const u16 * input, ssize_t max_len)
|
||||
{
|
||||
for (int i = 0; i < max_len; i++) if (input[i] == 0) return i;
|
||||
|
||||
Reference in New Issue
Block a user