summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2012-04-06 20:21:29 +0200
committerJens Arnold <amiconn@rockbox.org>2012-05-19 01:42:53 +0200
commit2d9c0bab540274e99480d965f38f266d20097976 (patch)
treee004fcdc65cd091521ca12575b82e672cc5908e3 /tools
parent4a6b875eda8fe7827b8a55e42e48184a6588ee4c (diff)
downloadrockbox-2d9c0bab540274e99480d965f38f266d20097976.zip
rockbox-2d9c0bab540274e99480d965f38f266d20097976.tar.gz
rockbox-2d9c0bab540274e99480d965f38f266d20097976.tar.bz2
rockbox-2d9c0bab540274e99480d965f38f266d20097976.tar.xz
Add support for cp1252 (Western European) codepage.
In Europe Windows defaults to its own codepage cp1252 (also known as "WinLatin" or "Windows-1252"). cp1252 adds some characters to ISO-8859-1. Some mp3 tagging software on Windows uses cp1252 instead of ISO-8859-1. This violates the ID3 specification, which requires tags to be ISO-8859-1 or Unicode. However, similar violations are made for other codepages and supported by Rockbox using the "Default Codepage" setting. Add support for cp1252 to enable people using such broken tools to override the correct decoding to get their tags displayed properly. Change-Id: I9f2ec478afe2503e99ee8e6609416c92b0f453e0 Reviewed-on: http://gerrit.rockbox.org/209 Reviewed-by: Jens Arnold <amiconn@rockbox.org> Tested-by: Jens Arnold <amiconn@rockbox.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/codepage_tables.c7
-rw-r--r--tools/codepage_tables.h1
-rw-r--r--tools/codepages.c22
3 files changed, 24 insertions, 6 deletions
diff --git a/tools/codepage_tables.c b/tools/codepage_tables.c
index 87e0da8..3f04c9d 100644
--- a/tools/codepage_tables.c
+++ b/tools/codepage_tables.c
@@ -57,6 +57,13 @@ const unsigned short cp1251_to_uni[] = {
0x0451, 0x2116, 0x0454, 0x00BB, 0x0458, 0x0405, 0x0455, 0x0457 /* B8-BF */
};
+const unsigned short cp1252_to_uni[] = {
+ 0x20AC, 0x00A0, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, /* 80-87 */
+ 0x0c26, 0x2030, 0x0160, 0x2039, 0x0152, 0x00a0, 0x017D, 0x00a0, /* 88-8F */
+ 0x00A0, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, /* 90-97 */
+ 0x02dc, 0x2122, 0x0161, 0x203A, 0x0153, 0x00a0, 0x017E, 0x0178 /* 98-9F */
+};
+
const unsigned short cp1256_to_uni[] = {
0x20AC, 0x067E, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
0x02C6, 0x2030, 0x0679, 0x2039, 0x0152, 0x0686, 0x0698, 0x0688,
diff --git a/tools/codepage_tables.h b/tools/codepage_tables.h
index 5c74baa..208a4c9 100644
--- a/tools/codepage_tables.h
+++ b/tools/codepage_tables.h
@@ -22,6 +22,7 @@
extern const unsigned short iso8859_7_to_uni[];
extern const unsigned short cp1250_to_uni[];
extern const unsigned short cp1251_to_uni[];
+extern const unsigned short cp1252_to_uni[];
extern const unsigned short cp1256_to_uni[];
extern const unsigned short iso8859_2_to_uni[];
extern const unsigned short cp932_table[];
diff --git a/tools/codepages.c b/tools/codepages.c
index 9c21439..fb01c4d 100644
--- a/tools/codepages.c
+++ b/tools/codepages.c
@@ -25,8 +25,8 @@
#define MAX_TABLE_SIZE 32768
-static const int mini_index[6] = {
- 0, 1, 3, 6, 7, 8
+static const int mini_index[7] = {
+ 0, 1, 3, 6, 7, 8, 9
};
static unsigned short iso_table[MAX_TABLE_SIZE];
@@ -140,7 +140,7 @@ unsigned short iso_decode(unsigned char *latin1, int cp, int count)
ucs = iso8859_2_to_uni[*latin1++ - 0xA1];
}
break;
-
+
case 0x08: /* Central European (CP1250) */
while (count--) {
/* first convert to unicode */
@@ -150,7 +150,17 @@ unsigned short iso_decode(unsigned char *latin1, int cp, int count)
ucs = cp1250_to_uni[*latin1++ - 0x80];
}
break;
-
+
+ case 0x09: /* Western European (CP1252) */
+ while (count--) {
+ /* first convert to unicode */
+ if (*latin1 < 0x80 || *latin1 >= 0xa0)
+ ucs = *latin1++;
+ else
+ ucs = cp1252_to_uni[*latin1++ - 0x80];
+ }
+ break;
+
default:
break;
}
@@ -209,7 +219,7 @@ int main(int argc, char **argv)
of = fopen("isomini.cp", "wb");
if (!of) return 1;
- for (i=1; i<6; i++) {
+ for (i=1; i<7; i++) {
for (j=0; j<128; j++) {
k = (unsigned char)j + 128;
@@ -223,7 +233,7 @@ int main(int argc, char **argv)
of = fopen("iso.cp", "wb");
if (!of) return 1;
- for (i=1; i<9; i++) {
+ for (i=1; i<10; i++) {
for (j=0; j<128; j++) {
k = (unsigned char)j + 128;