From 2bc47b299d491ad10978bdc26b8fc23c4e98f85b Mon Sep 17 00:00:00 2001 From: Pk11 Date: Sat, 21 Aug 2021 17:39:39 -0500 Subject: [PATCH] Propely substr file names --- arm9/source/file_browse.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arm9/source/file_browse.cpp b/arm9/source/file_browse.cpp index bd1131e..5688616 100644 --- a/arm9/source/file_browse.cpp +++ b/arm9/source/file_browse.cpp @@ -147,7 +147,13 @@ void showDirectoryContents(std::vector &dirContents, int fileOffset, i if(entry->size == -1) entry->size = getFileSize(entry->name.c_str()); - font->print(0, i + 1, true, entry->name.substr(0, SCREEN_COLS), Alignment::left, pal); + int nameSize = 0; + for(int i = 0; i < SCREEN_COLS; nameSize++) { + if((entry->name[nameSize] & 0xC0) != 0x80) + i++; + } + + font->print(0, i + 1, true, entry->name.substr(0, nameSize), Alignment::left, pal); if (entry->name == "..") { font->print(-1, i + 1, true, "(..)", Alignment::right, pal); } else if (entry->isDirectory) {