all repos — mgba @ d82f8feef5bdadccb07f308b0382cd650250ba03

mGBA Game Boy Advance Emulator

PSP2: Allow UTF-8 filenames
Jeffrey Pfau jeffrey@endrift.com
Thu, 18 Aug 2016 10:06:30 -0700
commit

d82f8feef5bdadccb07f308b0382cd650250ba03

parent

57c127589067d0b6e94083043134c2e5ac732449

4 files changed, 9 insertions(+), 11 deletions(-)

jump to
M CHANGESCHANGES

@@ -60,6 +60,7 @@ - PSP2: Sync files per descriptor

- GBA Savedata: Add realistic timing for EEPROM - GBA Video: Optimize mode 0 rendering - Qt: Remove default autofire mappings + - PSP2: Allow UTF-8 filenames 0.4.1: (2016-07-11) Bugfixes:
M src/platform/psp2/gui-font.csrc/platform/psp2/gui-font.c

@@ -41,10 +41,8 @@ return vita2d_pgf_text_height(font->pgf, FONT_SIZE, "M") + 9;

} unsigned GUIFontGlyphWidth(const struct GUIFont* font, uint32_t glyph) { - if (glyph > 0x7F) { - glyph = '?'; - } - char base[5] = { glyph }; + char base[5] = { 0 }; + toUtf8(glyph, base); return vita2d_pgf_text_width(font->pgf, FONT_SIZE, base); }

@@ -68,10 +66,8 @@ }

} void GUIFontDrawGlyph(const struct GUIFont* font, int x, int y, uint32_t color, uint32_t glyph) { - if (glyph > 0x7F) { - glyph = '?'; - } - char base[5] = { glyph }; + char base[5] = { 0 }; + toUtf8(glyph, base); vita2d_pgf_draw_text(font->pgf, x, y, color, FONT_SIZE, base); }
M src/util/string.csrc/util/string.c

@@ -80,7 +80,7 @@ if (!(byte & 0x80)) {

return byte; } uint32_t unichar; - static int tops[4] = { 0xC0, 0xE0, 0xF0, 0xF8 }; + static const int tops[4] = { 0xC0, 0xE0, 0xF0, 0xF8 }; size_t numBytes; for (numBytes = 0; numBytes < 3; ++numBytes) { if ((byte & tops[numBytes + 1]) == tops[numBytes]) {

@@ -110,7 +110,7 @@ }

return unichar; } -static size_t _toUtf8(uint32_t unichar, char* buffer) { +size_t toUtf8(uint32_t unichar, char* buffer) { if (unichar > 0x10FFFF) { unichar = 0xFFFD; }

@@ -173,7 +173,7 @@ if (length == 0) {

break; } uint32_t unichar = utf16Char(&utf16, &length); - size_t bytes = _toUtf8(unichar, buffer); + size_t bytes = toUtf8(unichar, buffer); utf8Length += bytes; if (utf8Length < utf8TotalBytes) { memcpy(offset, buffer, bytes);
M src/util/string.hsrc/util/string.h

@@ -19,6 +19,7 @@ #endif

char* strnrstr(const char* restrict s1, const char* restrict s2, size_t len); +size_t toUtf8(uint32_t unichar, char* buffer); int utfcmp(const uint16_t* utf16, const char* utf8, size_t utf16Length, size_t utf8Length); char* utf16to8(const uint16_t* utf16, size_t length); uint32_t utf8Char(const char** unicode, size_t* length);