Properly discard un-displayable UTF-16 chars

addresses #68
This commit is contained in:
d0k3 2017-05-31 23:42:33 +02:00
parent 7505c0b212
commit 7df545da18
3 changed files with 3 additions and 3 deletions

View File

@ -49,7 +49,7 @@ u32 LoadTwlMetaData(const char* path, TwlHeader* hdr, TwlIconData* icon) {
u32 GetTwlTitle(char* desc, const TwlIconData* twl_icon) { u32 GetTwlTitle(char* desc, const TwlIconData* twl_icon) {
const u16* title = twl_icon->title_eng; // english title const u16* title = twl_icon->title_eng; // english title
memset(desc, 0, TWLICON_SIZE_DESC + 1); memset(desc, 0, TWLICON_SIZE_DESC + 1);
for (u32 i = 0; i < TWLICON_SIZE_DESC; i++) desc[i] = title[i]; for (u32 i = 0; i < TWLICON_SIZE_DESC; i++) desc[i] = (title[i] >= 0x80) ? ' ' : title[i];
return 0; return 0;
} }

View File

@ -1,6 +1,6 @@
#include "smdh.h" #include "smdh.h"
#define SMDH_STRING(str, src, len) for (u32 i = 0; i < len; i++) str[i] = src[i] #define SMDH_STRING(str, src, len) for (u32 i = 0; i < len; i++) str[i] = (src[i] >= 0x80) ? ' ' : src[i]
// shamelessly stolen from bch2obj.py / 3ds_hb_menu :) // shamelessly stolen from bch2obj.py / 3ds_hb_menu :)
#define SMDH_LUT 0, 1, 8, 9, 2, 3, 10, 11, 16, 17, 24, 25, 18, 19, 26, 27, \ #define SMDH_LUT 0, 1, 8, 9, 2, 3, 10, 11, 16, 17, 24, 25, 18, 19, 26, 27, \
4, 5, 12, 13, 6, 7, 14, 15, 20, 21, 28, 29, 22, 23, 30, 31, \ 4, 5, 12, 13, 6, 7, 14, 15, 20, 21, 28, 29, 22, 23, 30, 31, \

View File

@ -744,7 +744,7 @@ bool GetVGameLv3Filename(char* name, const VirtualFile* vfile, u32 n_chars) {
} }
memset(name, 0, n_chars); memset(name, 0, n_chars);
for (u32 i = 0; (i < (n_chars-1)) && (i < name_len); i++) for (u32 i = 0; (i < (n_chars-1)) && (i < name_len); i++)
name[i] = wname[i]; // poor mans UTF-16 -> UTF-8 name[i] = wname[i]; // poor mans UTF-16 -> UTF-8 (doesn't work proper for special chars)
return true; return true;
} }