mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-09 13:15:18 -05:00
Cleaned up codepage handling, by Yoshihisa Uchida. (FS#9349)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19339 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
38e97057a9
commit
af078b4f86
5 changed files with 119 additions and 49 deletions
|
|
@ -620,6 +620,7 @@ static const struct plugin_api rockbox_api = {
|
|||
/* new stuff at the end, sort into place next time
|
||||
the API gets incompatible */
|
||||
get_settings_list,
|
||||
get_codepage_name,
|
||||
};
|
||||
|
||||
int plugin_load(const char* plugin, const void* parameter)
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ void* plugin_get_buffer(size_t *buffer_size);
|
|||
#define PLUGIN_MAGIC 0x526F634B /* RocK */
|
||||
|
||||
/* increase this every time the api struct changes */
|
||||
#define PLUGIN_API_VERSION 127
|
||||
#define PLUGIN_API_VERSION 128
|
||||
|
||||
/* update this to latest version if a change to the api struct breaks
|
||||
backwards compatibility (and please take the opportunity to sort in any
|
||||
|
|
@ -783,7 +783,7 @@ struct plugin_api {
|
|||
/* new stuff at the end, sort into place next time
|
||||
the API gets incompatible */
|
||||
const struct settings_list* (*get_settings_list)(int*count);
|
||||
|
||||
const char* (*get_codepage_name)(int cp);
|
||||
};
|
||||
|
||||
/* plugin header */
|
||||
|
|
|
|||
|
|
@ -348,23 +348,7 @@ struct preferences {
|
|||
WIDE,
|
||||
} view_mode;
|
||||
|
||||
enum {
|
||||
ISO_8859_1=0,
|
||||
ISO_8859_7,
|
||||
ISO_8859_8,
|
||||
CP1251,
|
||||
ISO_8859_11,
|
||||
ISO_8859_6,
|
||||
ISO_8859_9,
|
||||
ISO_8859_2,
|
||||
CP1250,
|
||||
SJIS,
|
||||
GB2312,
|
||||
KSX1001,
|
||||
BIG5,
|
||||
UTF8,
|
||||
ENCODINGS
|
||||
} encoding; /* FIXME: What should default encoding be? */
|
||||
enum codepages encoding;
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
enum {
|
||||
|
|
@ -433,16 +417,18 @@ unsigned char* get_ucs(const unsigned char* str, unsigned short* ch)
|
|||
unsigned char utf8_tmp[6];
|
||||
int count;
|
||||
|
||||
if (prefs.encoding == UTF8)
|
||||
if (prefs.encoding == UTF_8)
|
||||
return (unsigned char*)rb->utf8decode(str, ch);
|
||||
|
||||
count = BUFFER_OOB(str+2)? 1:2;
|
||||
rb->iso_decode(str, utf8_tmp, prefs.encoding, count);
|
||||
rb->utf8decode(utf8_tmp, ch);
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
if ((prefs.encoding == SJIS && *str > 0xA0 && *str < 0xE0) || prefs.encoding < SJIS)
|
||||
return (unsigned char*)str+1;
|
||||
else
|
||||
#endif
|
||||
return (unsigned char*)str+2;
|
||||
}
|
||||
|
||||
|
|
@ -1330,22 +1316,14 @@ static int col_limit(int col)
|
|||
|
||||
static bool encoding_setting(void)
|
||||
{
|
||||
static const struct opt_items names[] = {
|
||||
{"ISO-8859-1", -1},
|
||||
{"ISO-8859-7", -1},
|
||||
{"ISO-8859-8", -1},
|
||||
{"CP1251", -1},
|
||||
{"ISO-8859-11", -1},
|
||||
{"ISO-8859-6", -1},
|
||||
{"ISO-8859-9", -1},
|
||||
{"ISO-8859-2", -1},
|
||||
{"CP1250", -1},
|
||||
{"SJIS", -1},
|
||||
{"GB-2312", -1},
|
||||
{"KSX-1001", -1},
|
||||
{"BIG5", -1},
|
||||
{"UTF-8", -1},
|
||||
};
|
||||
static struct opt_items names[NUM_CODEPAGES];
|
||||
int idx;
|
||||
|
||||
for (idx = 0; idx < NUM_CODEPAGES; idx++)
|
||||
{
|
||||
names[idx].string = rb->get_codepage_name(idx);
|
||||
names[idx].voice_id = -1;
|
||||
}
|
||||
|
||||
return rb->set_option("Encoding", &prefs.encoding, INT, names,
|
||||
sizeof(names) / sizeof(names[0]), NULL);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue