summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/settings_list.c18
-rw-r--r--firmware/common/unicode.c73
-rw-r--r--firmware/include/rbunicode.h4
-rwxr-xr-xtools/buildzip.pl15
-rw-r--r--tools/codepages.c115
-rwxr-xr-xtools/configure12
6 files changed, 165 insertions, 72 deletions
diff --git a/apps/settings_list.c b/apps/settings_list.c
index 4dce7ae157..2b9457e1b0 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -947,18 +947,28 @@ const struct settings_list settings[] = {
OFFON_SETTING(0,tagcache_autoupdate,
LANG_TAGCACHE_AUTOUPDATE,false,"tagcache_autoupdate",NULL),
#endif
+#ifdef HAVE_LCD_BITMAP
CHOICE_SETTING(0, default_codepage, LANG_DEFAULT_CODEPAGE, 0,
- "default codepage",
+ "default codepage", /* The order must match with that in unicode.c */
"iso8859-1,iso8859-7,iso8859-8,cp1251,iso8859-11,cp1256,"
- "iso8859-9,iso8859-2,sjis,gb2312,ksx1001,big5,utf-8,cp1256",
+ "iso8859-9,iso8859-2,sjis,gb2312,ksx1001,big5,utf-8",
set_codepage, 13,
ID2P(LANG_CODEPAGE_LATIN1), ID2P(LANG_CODEPAGE_GREEK),
ID2P(LANG_CODEPAGE_HEBREW), ID2P(LANG_CODEPAGE_CYRILLIC),
ID2P(LANG_CODEPAGE_THAI), ID2P(LANG_CODEPAGE_ARABIC),
ID2P(LANG_CODEPAGE_TURKISH), ID2P(LANG_CODEPAGE_LATIN_EXTENDED),
ID2P(LANG_CODEPAGE_JAPANESE), ID2P(LANG_CODEPAGE_SIMPLIFIED),
- ID2P(LANG_CODEPAGE_KOREAN),
- ID2P(LANG_CODEPAGE_TRADITIONAL), ID2P(LANG_CODEPAGE_UTF8)),
+ ID2P(LANG_CODEPAGE_KOREAN), ID2P(LANG_CODEPAGE_TRADITIONAL),
+ ID2P(LANG_CODEPAGE_UTF8)),
+#else /* !HAVE_LCD_BITMAP */
+ CHOICE_SETTING(0, default_codepage, LANG_DEFAULT_CODEPAGE, 0,
+ "default codepage", /* The order must match with that in unicode.c */
+ "iso8859-1,iso8859-7,cp1251,iso8859-9,iso8859-2,utf-8",
+ set_codepage, 6,
+ ID2P(LANG_CODEPAGE_LATIN1), ID2P(LANG_CODEPAGE_GREEK),
+ ID2P(LANG_CODEPAGE_CYRILLIC), ID2P(LANG_CODEPAGE_TURKISH),
+ ID2P(LANG_CODEPAGE_LATIN_EXTENDED), ID2P(LANG_CODEPAGE_UTF8)),
+#endif
OFFON_SETTING(0,warnon_erase_dynplaylist,
LANG_WARN_ERASEDYNPLAYLIST_MENU,false,
diff --git a/firmware/common/unicode.c b/firmware/common/unicode.c
index 34c11369f2..50caa55667 100644
--- a/firmware/common/unicode.c
+++ b/firmware/common/unicode.c
@@ -17,19 +17,20 @@
#define O_BINARY 0
#endif
-#define NUM_TABLES 5
-#define NUM_CODEPAGES 13
-
+#define CODEPAGE_DIR "/.rockbox/codepages"
static int default_codepage = 0;
-static unsigned short codepage_table[MAX_CP_TABLE_SIZE];
static int loaded_cp_table = 0;
+#ifdef HAVE_LCD_BITMAP
-static const unsigned char utf8comp[6] =
-{
- 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC
-};
+#define MAX_CP_TABLE_SIZE 32768
+#define NUM_TABLES 5
+enum {
+ ISO_8859_1 = 0, ISO_8859_7, ISO_8859_8, WIN_1251,
+ ISO_8859_11, WIN_1256, ISO_8859_9, ISO_8859_2,
+ SJIS, GB_2312, KSX_1001, BIG_5, UTF_8, NUM_CODEPAGES
+};
static const char *filename[NUM_TABLES] =
{
CODEPAGE_DIR"/iso.cp",
@@ -38,12 +39,38 @@ static const char *filename[NUM_TABLES] =
CODEPAGE_DIR"/949.cp", /* KSX1001 */
CODEPAGE_DIR"/950.cp" /* BIG5 */
};
-
static const char cp_2_table[NUM_CODEPAGES] =
{
0, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 0
};
+#else /* !HAVE_LCD_BITMAP, reduced support */
+
+#define MAX_CP_TABLE_SIZE 512
+#define NUM_TABLES 1
+
+enum {
+ ISO_8859_1 = 0, ISO_8859_7, WIN_1251,
+ ISO_8859_9, ISO_8859_2, UTF_8, NUM_CODEPAGES
+};
+static const char *filename[NUM_TABLES] =
+{
+ CODEPAGE_DIR"/isomini.cp",
+};
+static const char cp_2_table[NUM_CODEPAGES] =
+{
+ 0, 1, 1, 1, 1, 0
+};
+
+#endif
+
+static unsigned short codepage_table[MAX_CP_TABLE_SIZE];
+
+static const unsigned char utf8comp[6] =
+{
+ 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC
+};
+
/* Load codepage file into memory */
static int load_cp_table(int cp)
{
@@ -113,34 +140,37 @@ unsigned char* iso_decode(const unsigned char *iso, unsigned char *utf8,
if (!load_cp_table(cp)) cp = 0;
while (count--) {
- if (*iso < 128 || cp == 0x0C) /* Already UTF-8 */
+ if (*iso < 128 || cp == UTF_8) /* Already UTF-8 */
*utf8++ = *iso++;
else {
/* cp tells us which codepage to convert from */
switch (cp) {
- case 0x01: /* Greek (ISO-8859-7) */
- case 0x02: /* Hebrew (ISO-8859-8) */
- case 0x03: /* Cyrillic (CP1251) */
- case 0x04: /* Thai (ISO-8859-11) */
- case 0x05: /* Arabic (CP1256) */
- case 0x06: /* Turkish (ISO-8859-9) */
- case 0x07: /* Latin Extended (ISO-8859-2) */
+ case ISO_8859_7: /* Greek */
+ case WIN_1251: /* Cyrillic */
+ case ISO_8859_9: /* Turkish */
+ case ISO_8859_2: /* Latin Extended */
+#ifdef HAVE_LCD_BITMAP
+ case ISO_8859_8: /* Hebrew */
+ case ISO_8859_11: /* Thai */
+ case WIN_1256: /* Arabic */
+#endif
tmp = ((cp-1)*128) + (*iso++ - 128);
ucs = codepage_table[tmp];
break;
- case 0x08: /* Japanese (SJIS) */
+#ifdef HAVE_LCD_BITMAP
+ case SJIS: /* Japanese */
if (*iso > 0xA0 && *iso < 0xE0) {
tmp = *iso++ | (0xA100 - 0x8000);
ucs = codepage_table[tmp];
break;
}
- case 0x09: /* Simplified Chinese (GB2312) */
- case 0x0A: /* Korean (KSX1001) */
- case 0x0B: /* Traditional Chinese (BIG5) */
+ case GB_2312: /* Simplified Chinese */
+ case KSX_1001: /* Korean */
+ case BIG5: /* Traditional Chinese */
if (count < 1 || !iso[1]) {
ucs = *iso++;
break;
@@ -154,6 +184,7 @@ unsigned char* iso_decode(const unsigned char *iso, unsigned char *utf8,
ucs = codepage_table[tmp];
count--;
break;
+#endif /* HAVE_LCD_BITMAP */
default:
ucs = *iso++;
diff --git a/firmware/include/rbunicode.h b/firmware/include/rbunicode.h
index a9ab49f280..6e61905685 100644
--- a/firmware/include/rbunicode.h
+++ b/firmware/include/rbunicode.h
@@ -8,10 +8,6 @@
* http://en.wikipedia.org/wiki/Unicode
*/
-#define CODEPAGE_DIR "/.rockbox/codepages"
-
-#define MAX_CP_TABLE_SIZE 32768
-
#define MASK 0xC0 /* 11000000 */
#define COMP 0x80 /* 10x */
diff --git a/tools/buildzip.pl b/tools/buildzip.pl
index 0463132ec4..3ddb0163d3 100755
--- a/tools/buildzip.pl
+++ b/tools/buildzip.pl
@@ -178,9 +178,18 @@ sub buildzip {
}
mkdir ".rockbox/wps", 0777;
+ mkdir ".rockbox/codepages", 0777;
+
+ if($bitmap) {
+ system("$ROOT/tools/codepages");
+ }
+ else {
+ system("$ROOT/tools/codepages -m");
+ }
+ $c = 'find . -name "*.cp" ! -empty -exec mv {} .rockbox/codepages/ \; >/dev/null 2>&1';
+ `$c`;
if($bitmap) {
- mkdir ".rockbox/codepages", 0777;
mkdir ".rockbox/codecs", 0777;
mkdir ".rockbox/themes", 0777;
if($depth > 1) {
@@ -190,10 +199,6 @@ sub buildzip {
my $c = 'find apps -name "*.codec" ! -empty -exec cp {} .rockbox/codecs/ \; 2>/dev/null';
`$c`;
- system("$ROOT/tools/codepages");
- $c = 'find . -name "*.cp" ! -empty -exec mv {} .rockbox/codepages/ \; >/dev/null 2>&1';
- `$c`;
-
my @call = `find .rockbox/codecs -type f 2>/dev/null`;
if(!$call[0]) {
# no codec was copied, remove directory again
diff --git a/tools/codepages.c b/tools/codepages.c
index e19d39c85a..651a99c429 100644
--- a/tools/codepages.c
+++ b/tools/codepages.c
@@ -23,6 +23,10 @@
#define MAX_TABLE_SIZE 32768
+static const int mini_index[5] = {
+ 0, 1, 3, 6, 7
+};
+
static unsigned short iso_table[MAX_TABLE_SIZE];
unsigned short iso_decode(unsigned char *latin1, int cp, int count)
@@ -147,53 +151,100 @@ int writeshort(FILE *f, unsigned short s)
return putc(s>>8, f) != EOF;
}
-int main(void)
+void print_usage(void)
{
+ printf("Usage: codepages [-m]\n"
+ "\t-m Create isomini.cp only\n");
+ printf("build date: " __DATE__ "\n\n");
+}
+int main(int argc, char **argv)
+{
+ int mini = 0;
int i, j;
unsigned char k;
unsigned short uni;
FILE *of;
+ for (i = 1;i < argc;i++)
+ {
+ if (argv[i][0] == '-')
+ {
+ switch (argv[i][1])
+ {
+ case 'm': /* create isomini.cp only */
+ mini = 1;
+ break;
+
+ case 'h': /* help */
+ case '?':
+ print_usage();
+ exit(1);
+ break;
+
+ default:
+ print_usage();
+ exit(1);
+ break;
+ }
+ }
+ }
+
for (i=0; i < MAX_TABLE_SIZE; i++)
iso_table[i] = 0;
- of = fopen("iso.cp", "wb");
- if (!of) return 1;
+ if (mini) {
+ of = fopen("isomini.cp", "wb");
+ if (!of) return 1;
- for (i=1; i<8; i++) {
+ for (i=1; i<5; i++) {
- for (j=0; j<128; j++) {
- k = (unsigned char)j + 128;
- uni = iso_decode(&k, i, 1);
- writeshort(of, uni);
+ for (j=0; j<128; j++) {
+ k = (unsigned char)j + 128;
+ uni = iso_decode(&k, mini_index[i], 1);
+ writeshort(of, uni);
+ }
}
+ fclose(of);
}
- fclose(of);
+ else {
+ of = fopen("iso.cp", "wb");
+ if (!of) return 1;
- of = fopen("932.cp", "wb");
- if (!of) return 1;
- for (i=0; i < MAX_TABLE_SIZE; i++)
- writeshort(of, cp932_table[i]);
- fclose(of);
-
- of = fopen("936.cp", "wb");
- if (!of) return 1;
- for (i=0; i < MAX_TABLE_SIZE; i++)
- writeshort(of, cp936_table[i]);
- fclose(of);
-
- of = fopen("949.cp", "wb");
- if (!of) return 1;
- for (i=0; i < MAX_TABLE_SIZE; i++)
- writeshort(of, cp949_table[i]);
- fclose(of);
-
- of = fopen("950.cp", "wb");
- if (!of) return 1;
- for (i=0; i < MAX_TABLE_SIZE; i++)
- writeshort(of, cp950_table[i]);
- fclose(of);
+ for (i=1; i<8; i++) {
+
+ for (j=0; j<128; j++) {
+ k = (unsigned char)j + 128;
+ uni = iso_decode(&k, i, 1);
+ writeshort(of, uni);
+ }
+ }
+ fclose(of);
+
+ of = fopen("932.cp", "wb");
+ if (!of) return 1;
+ for (i=0; i < MAX_TABLE_SIZE; i++)
+ writeshort(of, cp932_table[i]);
+ fclose(of);
+
+ of = fopen("936.cp", "wb");
+ if (!of) return 1;
+ for (i=0; i < MAX_TABLE_SIZE; i++)
+ writeshort(of, cp936_table[i]);
+ fclose(of);
+
+ of = fopen("949.cp", "wb");
+ if (!of) return 1;
+ for (i=0; i < MAX_TABLE_SIZE; i++)
+ writeshort(of, cp949_table[i]);
+ fclose(of);
+
+ of = fopen("950.cp", "wb");
+ if (!of) return 1;
+ for (i=0; i < MAX_TABLE_SIZE; i++)
+ writeshort(of, cp950_table[i]);
+ fclose(of);
+ }
return 0;
}
diff --git a/tools/configure b/tools/configure
index 1b469c855b..0341a29e85 100755
--- a/tools/configure
+++ b/tools/configure
@@ -598,16 +598,16 @@ EOF
buildfor=`input`;
# Set of tools built for all target platforms:
- toolset="rdf2binary convbdf"
+ toolset="rdf2binary convbdf codepages"
# Toolsets for some target families:
- archosbitmaptools="$toolset scramble descramble sh2d uclpack bmp2rb codepages"
- iriverbitmaptools="$toolset scramble descramble mkboot bmp2rb codepages"
- iaudiobitmaptools="$toolset scramble descramble mkboot bmp2rb codepages"
+ archosbitmaptools="$toolset scramble descramble sh2d uclpack bmp2rb"
+ iriverbitmaptools="$toolset scramble descramble mkboot bmp2rb"
+ iaudiobitmaptools="$toolset scramble descramble mkboot bmp2rb"
ipodbitmaptools="$toolset scramble ipod_fw bmp2rb codepages"
- gigabeatbitmaptools="$toolset scramble descramble bmp2rb codepages"
+ gigabeatbitmaptools="$toolset scramble descramble bmp2rb"
# generic is used by IFP, H10, Sansa-e200
- genericbitmaptools="$toolset bmp2rb codepages"
+ genericbitmaptools="$toolset bmp2rb"
# ---- For each target ----