diff options
author | Björn Stenberg <bjorn@haxx.se> | 2008-12-04 22:00:12 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2008-12-04 22:00:12 +0000 |
commit | af078b4f86cb124778073905b2c28cc2d9b7748b (patch) | |
tree | 10493ea7cbd4239f847ea10b2aa73e2c33ba9e02 /apps/plugins/viewer.c | |
parent | 38e97057a9f9bf3c3f09c128266874c0cca89950 (diff) | |
download | rockbox-af078b4f86cb124778073905b2c28cc2d9b7748b.tar.gz rockbox-af078b4f86cb124778073905b2c28cc2d9b7748b.zip |
Cleaned up codepage handling, by Yoshihisa Uchida. (FS#9349)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19339 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/viewer.c')
-rw-r--r-- | apps/plugins/viewer.c | 46 |
1 files changed, 12 insertions, 34 deletions
diff --git a/apps/plugins/viewer.c b/apps/plugins/viewer.c index 76c1d93c1c..4cef7c5879 100644 --- a/apps/plugins/viewer.c +++ b/apps/plugins/viewer.c | |||
@@ -348,23 +348,7 @@ struct preferences { | |||
348 | WIDE, | 348 | WIDE, |
349 | } view_mode; | 349 | } view_mode; |
350 | 350 | ||
351 | enum { | 351 | enum codepages encoding; |
352 | ISO_8859_1=0, | ||
353 | ISO_8859_7, | ||
354 | ISO_8859_8, | ||
355 | CP1251, | ||
356 | ISO_8859_11, | ||
357 | ISO_8859_6, | ||
358 | ISO_8859_9, | ||
359 | ISO_8859_2, | ||
360 | CP1250, | ||
361 | SJIS, | ||
362 | GB2312, | ||
363 | KSX1001, | ||
364 | BIG5, | ||
365 | UTF8, | ||
366 | ENCODINGS | ||
367 | } encoding; /* FIXME: What should default encoding be? */ | ||
368 | 352 | ||
369 | #ifdef HAVE_LCD_BITMAP | 353 | #ifdef HAVE_LCD_BITMAP |
370 | enum { | 354 | enum { |
@@ -433,16 +417,18 @@ unsigned char* get_ucs(const unsigned char* str, unsigned short* ch) | |||
433 | unsigned char utf8_tmp[6]; | 417 | unsigned char utf8_tmp[6]; |
434 | int count; | 418 | int count; |
435 | 419 | ||
436 | if (prefs.encoding == UTF8) | 420 | if (prefs.encoding == UTF_8) |
437 | return (unsigned char*)rb->utf8decode(str, ch); | 421 | return (unsigned char*)rb->utf8decode(str, ch); |
438 | 422 | ||
439 | count = BUFFER_OOB(str+2)? 1:2; | 423 | count = BUFFER_OOB(str+2)? 1:2; |
440 | rb->iso_decode(str, utf8_tmp, prefs.encoding, count); | 424 | rb->iso_decode(str, utf8_tmp, prefs.encoding, count); |
441 | rb->utf8decode(utf8_tmp, ch); | 425 | rb->utf8decode(utf8_tmp, ch); |
442 | 426 | ||
427 | #ifdef HAVE_LCD_BITMAP | ||
443 | if ((prefs.encoding == SJIS && *str > 0xA0 && *str < 0xE0) || prefs.encoding < SJIS) | 428 | if ((prefs.encoding == SJIS && *str > 0xA0 && *str < 0xE0) || prefs.encoding < SJIS) |
444 | return (unsigned char*)str+1; | 429 | return (unsigned char*)str+1; |
445 | else | 430 | else |
431 | #endif | ||
446 | return (unsigned char*)str+2; | 432 | return (unsigned char*)str+2; |
447 | } | 433 | } |
448 | 434 | ||
@@ -1330,22 +1316,14 @@ static int col_limit(int col) | |||
1330 | 1316 | ||
1331 | static bool encoding_setting(void) | 1317 | static bool encoding_setting(void) |
1332 | { | 1318 | { |
1333 | static const struct opt_items names[] = { | 1319 | static struct opt_items names[NUM_CODEPAGES]; |
1334 | {"ISO-8859-1", -1}, | 1320 | int idx; |
1335 | {"ISO-8859-7", -1}, | 1321 | |
1336 | {"ISO-8859-8", -1}, | 1322 | for (idx = 0; idx < NUM_CODEPAGES; idx++) |
1337 | {"CP1251", -1}, | 1323 | { |
1338 | {"ISO-8859-11", -1}, | 1324 | names[idx].string = rb->get_codepage_name(idx); |
1339 | {"ISO-8859-6", -1}, | 1325 | names[idx].voice_id = -1; |
1340 | {"ISO-8859-9", -1}, | 1326 | } |
1341 | {"ISO-8859-2", -1}, | ||
1342 | {"CP1250", -1}, | ||
1343 | {"SJIS", -1}, | ||
1344 | {"GB-2312", -1}, | ||
1345 | {"KSX-1001", -1}, | ||
1346 | {"BIG5", -1}, | ||
1347 | {"UTF-8", -1}, | ||
1348 | }; | ||
1349 | 1327 | ||
1350 | return rb->set_option("Encoding", &prefs.encoding, INT, names, | 1328 | return rb->set_option("Encoding", &prefs.encoding, INT, names, |
1351 | sizeof(names) / sizeof(names[0]), NULL); | 1329 | sizeof(names) / sizeof(names[0]), NULL); |