mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 20:30:41 +00:00
Bug 1169248 - Fix GBK/GB18030 encoders. r=smontagu
--HG-- rename : intl/uconv/tests/unit/test_encode_gbk.js => intl/uconv/tests/unit/test_encode_gb18030.js rename : intl/uconv/ucvcn/gbkuniq2b.uf => intl/uconv/ucvcn/gbkuniq.uf
This commit is contained in:
parent
b2e6518351
commit
f0a5679f8a
15
intl/uconv/tests/unit/test_encode_gb18030.js
Normal file
15
intl/uconv/tests/unit/test_encode_gb18030.js
Normal file
@ -0,0 +1,15 @@
|
||||
// Tests conversion from Unicode to gb18030
|
||||
// This is a sniff test which doesn't cover the full gbk range: the test string
|
||||
// includes only the ASCII range and the first 63 double byte characters
|
||||
|
||||
load('CharsetConversionTests.js');
|
||||
|
||||
const inString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u20AC\u4E02\u4E04\u4E05\u4E06\u4E0F\u4E12\u4E17\u4E1F\u4E20\u4E21\u4E23\u4E26\u4E29\u4E2E\u4E2F\u4E31\u4E33\u4E35\u4E37\u4E3C\u4E40\u4E41\u4E42\u4E44\u4E46\u4E4A\u4E51\u4E55\u4E57\u4E5A\u4E5B\u4E62\u4E63\u4E64\u4E65\u4E67\u4E68\u4E6A\u4E6B\u4E6C\u4E6D\u4E6E\u4E6F\u4E72\u4E74\u4E75\u4E76\u4E77\u4E78\u4E79\u4E7A\u4E7B\u4E7C\u4E7D\u4E7F\u4E80\u4E81\u4E82\u4E83\u4E84\u4E85\u4E87\u4E8A\uFFFD";
|
||||
|
||||
const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\xa2\xe3\x81@\x81A\x81B\x81C\x81D\x81E\x81F\x81G\x81H\x81I\x81J\x81K\x81L\x81M\x81N\x81O\x81P\x81Q\x81R\x81S\x81T\x81U\x81V\x81W\x81X\x81Y\x81Z\x81[\x81\\\x81]\x81^\x81_\x81`\x81a\x81b\x81c\x81d\x81e\x81f\x81g\x81h\x81i\x81j\x81k\x81l\x81m\x81n\x81o\x81p\x81q\x81r\x81s\x81t\x81u\x81v\x81w\x81x\x81y\x81z\x81{\x81|\x81}\x81~\x84\x31\xa4\x37";
|
||||
|
||||
const aliases = [ "gb18030" ];
|
||||
|
||||
function run_test() {
|
||||
testEncodeAliases();
|
||||
}
|
@ -4,9 +4,9 @@
|
||||
|
||||
load('CharsetConversionTests.js');
|
||||
|
||||
const inString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u4E02\u4E04\u4E05\u4E06\u4E0F\u4E12\u4E17\u4E1F\u4E20\u4E21\u4E23\u4E26\u4E29\u4E2E\u4E2F\u4E31\u4E33\u4E35\u4E37\u4E3C\u4E40\u4E41\u4E42\u4E44\u4E46\u4E4A\u4E51\u4E55\u4E57\u4E5A\u4E5B\u4E62\u4E63\u4E64\u4E65\u4E67\u4E68\u4E6A\u4E6B\u4E6C\u4E6D\u4E6E\u4E6F\u4E72\u4E74\u4E75\u4E76\u4E77\u4E78\u4E79\u4E7A\u4E7B\u4E7C\u4E7D\u4E7F\u4E80\u4E81\u4E82\u4E83\u4E84\u4E85\u4E87\u4E8A";
|
||||
const inString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u20AC\u4E02\u4E04\u4E05\u4E06\u4E0F\u4E12\u4E17\u4E1F\u4E20\u4E21\u4E23\u4E26\u4E29\u4E2E\u4E2F\u4E31\u4E33\u4E35\u4E37\u4E3C\u4E40\u4E41\u4E42\u4E44\u4E46\u4E4A\u4E51\u4E55\u4E57\u4E5A\u4E5B\u4E62\u4E63\u4E64\u4E65\u4E67\u4E68\u4E6A\u4E6B\u4E6C\u4E6D\u4E6E\u4E6F\u4E72\u4E74\u4E75\u4E76\u4E77\u4E78\u4E79\u4E7A\u4E7B\u4E7C\u4E7D\u4E7F\u4E80\u4E81\u4E82\u4E83\u4E84\u4E85\u4E87\u4E8A\uFFFD";
|
||||
|
||||
const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x81@\x81A\x81B\x81C\x81D\x81E\x81F\x81G\x81H\x81I\x81J\x81K\x81L\x81M\x81N\x81O\x81P\x81Q\x81R\x81S\x81T\x81U\x81V\x81W\x81X\x81Y\x81Z\x81[\x81\\\x81]\x81^\x81_\x81`\x81a\x81b\x81c\x81d\x81e\x81f\x81g\x81h\x81i\x81j\x81k\x81l\x81m\x81n\x81o\x81p\x81q\x81r\x81s\x81t\x81u\x81v\x81w\x81x\x81y\x81z\x81{\x81|\x81}\x81~";
|
||||
const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x80\x81@\x81A\x81B\x81C\x81D\x81E\x81F\x81G\x81H\x81I\x81J\x81K\x81L\x81M\x81N\x81O\x81P\x81Q\x81R\x81S\x81T\x81U\x81V\x81W\x81X\x81Y\x81Z\x81[\x81\\\x81]\x81^\x81_\x81`\x81a\x81b\x81c\x81d\x81e\x81f\x81g\x81h\x81i\x81j\x81k\x81l\x81m\x81n\x81o\x81p\x81q\x81r\x81s\x81t\x81u\x81v\x81w\x81x\x81y\x81z\x81{\x81|\x81}\x81~";
|
||||
|
||||
const aliases = [ "gbk", "x-gbk" ];
|
||||
|
||||
|
@ -101,6 +101,7 @@ support-files =
|
||||
[test_encode_CP1257.js]
|
||||
[test_encode_CP1258.js]
|
||||
[test_encode_CP874.js]
|
||||
[test_encode_gb18030.js]
|
||||
[test_encode_gbk.js]
|
||||
[test_encode_x_mac_arabic.js]
|
||||
[test_encode_x_mac_ce.js]
|
||||
|
@ -201,11 +201,11 @@ sub genufut()
|
||||
print ( "umaptable -ut < gb18030uniq.txt > gb18030uniq2b.ut\n");
|
||||
system( "umaptable -ut < gb18030uniq.txt > gb18030uniq2b.ut");
|
||||
|
||||
print ( "umaptable -uf < cp936uniq.txt > gbkuniq2b.uf\n") ;
|
||||
system( "umaptable -uf < cp936uniq.txt > gbkuniq2b.uf") ;
|
||||
print ( "umaptable -uf < cp936uniq.txt > gbkuniq.uf\n") ;
|
||||
system( "umaptable -uf < cp936uniq.txt > gbkuniq.uf") ;
|
||||
|
||||
print ( "umaptable -ut < cp936uniq.txt > gbkuniq2b.ut\n") ;
|
||||
system( "umaptable -ut < cp936uniq.txt > gbkuniq2b.ut") ;
|
||||
print ( "umaptable -ut < cp936uniq.txt > gbkuniq.ut\n") ;
|
||||
system( "umaptable -ut < cp936uniq.txt > gbkuniq.ut") ;
|
||||
|
||||
print ( "umaptable -uf < gb180304b.txt > gb180304bytes.uf\n") ;
|
||||
system( "umaptable -uf < gb180304b.txt > gb180304bytes.uf") ;
|
||||
|
@ -40,6 +40,8 @@ bool nsGBKConvUtil::UnicodeToGBKChar(
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else if (aChar == UCS2_NO_MAPPING) {
|
||||
return false;
|
||||
} else {
|
||||
// ugly linear search
|
||||
for( int32_t i = 0; i < MAX_GBK_LENGTH; i++ )
|
||||
|
@ -54,17 +54,17 @@ protected:
|
||||
};
|
||||
//-----------------------------------------------------------------------
|
||||
// Private class used by nsUnicodeToGBK
|
||||
// nsUnicodeToGBKUniq2Bytes
|
||||
// nsUnicodeToGBKUniq
|
||||
//-----------------------------------------------------------------------
|
||||
static const uint16_t g_uf_gbk_2bytes[] = {
|
||||
#include "gbkuniq2b.uf"
|
||||
static const uint16_t g_uf_gbk[] = {
|
||||
#include "gbkuniq.uf"
|
||||
};
|
||||
class nsUnicodeToGBKUniq2Bytes : public nsTableEncoderSupport
|
||||
class nsUnicodeToGBKUniq : public nsTableEncoderSupport
|
||||
{
|
||||
public:
|
||||
nsUnicodeToGBKUniq2Bytes()
|
||||
: nsTableEncoderSupport(u2BytesCharset,
|
||||
(uMappingTable*) &g_uf_gbk_2bytes, 2) {}
|
||||
nsUnicodeToGBKUniq()
|
||||
: nsTableEncoderSupport(u1ByteCharset,
|
||||
(uMappingTable*) &g_uf_gbk, 1) {}
|
||||
protected:
|
||||
};
|
||||
//-----------------------------------------------------------------------
|
||||
@ -116,7 +116,7 @@ nsUnicodeToGBK::nsUnicodeToGBK(uint32_t aMaxLength) :
|
||||
}
|
||||
void nsUnicodeToGBK::CreateExtensionEncoder()
|
||||
{
|
||||
mExtensionEncoder = new nsUnicodeToGBKUniq2Bytes();
|
||||
mExtensionEncoder = new nsUnicodeToGBKUniq();
|
||||
}
|
||||
void nsUnicodeToGBK::Create4BytesEncoder()
|
||||
{
|
||||
|
@ -1,8 +1,5 @@
|
||||
[gbk-encoder.html]
|
||||
type: testharness
|
||||
[gbk encoder: Euro]
|
||||
expected: FAIL
|
||||
|
||||
[gbk encoder: poo]
|
||||
expected: FAIL
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user