nls: fix the Unicode to charset tables of cp1251
PATCH 1/1 nls: fix the Unicode to charset tables of cp1251
Three of the uni2char() tables in nls_cp1251.c are incorrect, while charset2uni() matches the Unicode CP1251 mapping.
page00 incorrectly maps eight U+00xx characters that are not part of CP1251 to 0xbb. page04 is off by one for U+0490..U+0492, causing U+0491 to be stored as 0xa5 and U+0492 to be stored as 0xb4. page20 also stops at U+203F, so U+20AC can be decoded but not encoded.
Regenerate page00, page04 and page20 from charset2uni. glibc iconv agrees with the resulting mappings, and a full BMP round trip is now lossless.
Signed-off-by Ali Ahmet Memiş <[email protected]>
--- fs/nls/nls_cp1251.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-)
fs/nls/nls_cp1251.c +23 -9
@@ -122,14 +122,14 @@ static const unsigned char page00[256] = {0x00 ,0xa9 ,0x00 ,0xab ,0xac ,0xad ,0xae ,0x00 ,/* 0xa8-0xaf */ 0xb0 ,0xb1 ,0x00 ,0x00 ,0x00 ,0xb5 ,0xb6 ,0xb7 ,/* 0xb0-0xb7 */ 0x00 ,0x00 ,0x00 ,0xbb ,0x00 ,0x00 ,0x00 ,0x00 ,/* 0xb8-0xbf */ -0x00 ,0x00 ,0x00 ,0xbb ,0x00 ,0x00 ,0x00 ,0x00 ,/* 0xc0-0xc7 */ -0x00 ,0x00 ,0x00 ,0xbb ,0x00 ,0x00 ,0x00 ,0x00 ,/* 0xc8-0xcf */ -0x00 ,0x00 ,0x00 ,0xbb ,0x00 ,0x00 ,0x00 ,0x00 ,/* 0xd0-0xd7 */ -0x00 ,0x00 ,0x00 ,0xbb ,0x00 ,0x00 ,0x00 ,0x00 ,/* 0xd8-0xdf */ -0x00 ,0x00 ,0x00 ,0xbb ,0x00 ,0x00 ,0x00 ,0x00 ,/* 0xe0-0xe7 */ -0x00 ,0x00 ,0x00 ,0xbb ,0x00 ,0x00 ,0x00 ,0x00 ,/* 0xe8-0xef */ -0x00 ,0x00 ,0x00 ,0xbb ,0x00 ,0x00 ,0x00 ,0x00 ,/* 0xf0-0xf7 */ - 0x00, 0x00, 0x00, 0xbb, 0x00, 0x00, 0x00, 0x00, /* 0xf8-0xff */ +0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,/* 0xc0-0xc7 */ +0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,/* 0xc8-0xcf */ +0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,/* 0xd0-0xd7 */ +0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,/* 0xd8-0xdf */ +0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,/* 0xe0-0xe7 */ +0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,/* 0xe8-0xef */ +0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,/* 0xf0-0xf7 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf8-0xff */ }; static const unsigned char page04[256] = {
@@ -152,7 +152,7 @@ static const unsigned char page04[256] = {0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,/* 0x80-0x87 */ 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,/* 0x88-0x8f */ - 0x00, 0xa5, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ + 0xa5, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ }; static const unsigned char page20[256] = {
@@ -164,6 +164,20 @@ static const unsigned char page20[256] = {0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,/* 0x28-0x2f */ 0x89 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,/* 0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