Nugget
Loading...
Searching...
No Matches
sjis-title-encoder.hh
Go to the documentation of this file.
1/*
2
3MIT License
4
5Copyright (c) 2026 PCSX-Redux authors
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25*/
26
27#pragma once
28
29#include <stdint.h>
30
31// Registration seam for the memory-card save-title encoder.
32//
33// The filesystem encodes save titles through the g_titleEncoder function
34// pointer, which defaults to the lightweight ASCII-only encoder
35// (Sjis::asciiToSjisTitle, ~190 bytes of table). A program that needs to write
36// non-ASCII (e.g. Japanese) titles calls registerFullTitleEncoder() once at
37// startup to swap in the complete UTF-8 -> Shift-JIS converter. Because the
38// full encoder and its ~28kB table live in their own translation unit and are
39// only reachable through registerFullTitleEncoder(), --gc-sections drops the
40// table entirely from any program that never calls it.
41
42namespace Sjis {
43
44using TitleEncoder = uint32_t (*)(uint8_t* dst, uint32_t dstSize, const char* src);
45
46// The active title encoder. Defaults to Sjis::asciiToSjisTitle.
48
49// Installs the full UTF-8 -> Shift-JIS title encoder (pulls in the ~28kB
50// conversion table). Call once, before writing any non-ASCII title.
52
53} // namespace Sjis
Definition sjis-decode.hh:38
void registerFullTitleEncoder()
Definition sjis-full-title-encoder.cpp:39
TitleEncoder g_titleEncoder
Definition sjis-title-encoder.cpp:39
uint32_t(*)(uint8_t *dst, uint32_t dstSize, const char *src) TitleEncoder
Definition sjis-title-encoder.hh:44
static const char * src
Definition syscalls.h:80
void uint32_t(classId, spec)