Files
dusklight/libs/JSystem/src/JMessage/locale.cpp
T
Luke Street 4df8ccc871 Reorganize library code into libs/ (#3119)
* Reorganize files into libs/{dolphin,JSystem,PowerPC_EABI_Support,revolution,TRK_MINNOW_DOLPHIN}

* Update configure.py and project.py for new libs structure

* Refactor `#include <dolphin/x.h>` -> `<x.h>`

* Remove `__REVOLUTION_SDK__` forwards from dolphin

* Fix dolphin/ references in revolution

* Wrap `#include <dolphin.h>` in `!__REVOLUTION_SDK__`

* Always build TRK against dolphin headers

* Resolve revolution SDK header resolution issues
2026-03-01 14:35:36 -08:00

57 lines
1.3 KiB
C++

#include "JSystem/JSystem.h" // IWYU pragma: keep
#include "JSystem/JMessage/locale.h"
int JMessage::locale::parseCharacter_ShiftJIS(const char** ppszText) {
int c = *(u8*)*ppszText & 0xFF;
(*ppszText)++;
if (isLeadByte_ShiftJIS(c)) {
c <<= 8;
c |= *(u8*)*ppszText & 0xFF;
(*ppszText)++;
}
return c;
}
int JMessage::locale::parseCharacter_UTF8(const char** ppszText) {
int c = *(u8*)*ppszText & 0xFF;
(*ppszText)++;
if (c & 0x80) {
if ((c & 0xE0) == 0xC0) {
c &= 0x1F;
c <<= 6;
c |= (*(u8*)*ppszText & 0xFF) & 0x3F;
(*ppszText)++;
} else if ((c & 0xF0) == 0xE0) {
c &= 0xF;
c <<= 6;
c |= (*(u8*)*ppszText & 0xFF) & 0x3F;
(*ppszText)++;
c <<= 6;
c |= (*(u8*)*ppszText & 0xFF) & 0x3F;
(*ppszText)++;
} else if ((c & 0xF8) == 0xF0) {
c &= 0x7;
c <<= 6;
c |= (*(u8*)*ppszText & 0xFF) & 0x3F;
(*ppszText)++;
c <<= 6;
c |= (*(u8*)*ppszText & 0xFF) & 0x3F;
(*ppszText)++;
c <<= 6;
c |= (*(u8*)*ppszText & 0xFF) & 0x3F;
(*ppszText)++;
} else {
c = -1;
}
}
return c;
}