| OLD | NEW | 
|    1 /* |    1 /* | 
|    2  ********************************************************************** |    2  ********************************************************************** | 
|    3  *   Copyright (C) 2005-2013, International Business Machines |    3  *   Copyright (C) 2005-2015, International Business Machines | 
|    4  *   Corporation and others.  All Rights Reserved. |    4  *   Corporation and others.  All Rights Reserved. | 
|    5  ********************************************************************** |    5  ********************************************************************** | 
|    6  */ |    6  */ | 
|    7  |    7  | 
|    8  |    8  | 
|    9 #include "unicode/utypes.h" |    9 #include "unicode/utypes.h" | 
|   10 #include "unicode/ucsdet.h" |   10 #include "unicode/ucsdet.h" | 
|   11 #include "unicode/ucnv.h" |   11 #include "unicode/ucnv.h" | 
|   12 #include "unicode/unistr.h" |   12 #include "unicode/unistr.h" | 
|   13 #include "unicode/putil.h" |   13 #include "unicode/putil.h" | 
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  577         } |  577         } | 
|  578     } |  578     } | 
|  579  |  579  | 
|  580     delete root; |  580     delete root; | 
|  581     delete parser; |  581     delete parser; | 
|  582 #endif |  582 #endif | 
|  583 } |  583 } | 
|  584  |  584  | 
|  585 void CharsetDetectionTest::IBM424Test() |  585 void CharsetDetectionTest::IBM424Test() | 
|  586 { |  586 { | 
 |  587 #if !UCONFIG_ONLY_HTML_CONVERSION | 
|  587     UErrorCode status = U_ZERO_ERROR; |  588     UErrorCode status = U_ZERO_ERROR; | 
|  588      |  589      | 
|  589     static const UChar chars[] = { |  590     static const UChar chars[] = { | 
|  590             0x05D4, 0x05E4, 0x05E8, 0x05E7, 0x05DC, 0x05D9, 0x05D8, 0x0020, 0x05
     D4, 0x05E6, 0x05D1, 0x05D0, 0x05D9, 0x0020, 0x05D4, 0x05E8, |  591             0x05D4, 0x05E4, 0x05E8, 0x05E7, 0x05DC, 0x05D9, 0x05D8, 0x0020, 0x05
     D4, 0x05E6, 0x05D1, 0x05D0, 0x05D9, 0x0020, 0x05D4, 0x05E8, | 
|  591             0x05D0, 0x05E9, 0x05D9, 0x002C, 0x0020, 0x05EA, 0x05EA, 0x0020, 0x05
     D0, 0x05DC, 0x05D5, 0x05E3, 0x0020, 0x05D0, 0x05D1, 0x05D9, |  592             0x05D0, 0x05E9, 0x05D9, 0x002C, 0x0020, 0x05EA, 0x05EA, 0x0020, 0x05
     D0, 0x05DC, 0x05D5, 0x05E3, 0x0020, 0x05D0, 0x05D1, 0x05D9, | 
|  592             0x05D7, 0x05D9, 0x0020, 0x05DE, 0x05E0, 0x05D3, 0x05DC, 0x05D1, 0x05
     DC, 0x05D9, 0x05D8, 0x002C, 0x0020, 0x05D4, 0x05D5, 0x05E8, |  593             0x05D7, 0x05D9, 0x0020, 0x05DE, 0x05E0, 0x05D3, 0x05DC, 0x05D1, 0x05
     DC, 0x05D9, 0x05D8, 0x002C, 0x0020, 0x05D4, 0x05D5, 0x05E8, | 
|  593             0x05D4, 0x0020, 0x05E2, 0x05DC, 0x0020, 0x05E4, 0x05EA, 0x05D9, 0x05
     D7, 0x05EA, 0x0020, 0x05D7, 0x05E7, 0x05D9, 0x05E8, 0x05EA, |  594             0x05D4, 0x0020, 0x05E2, 0x05DC, 0x0020, 0x05E4, 0x05EA, 0x05D9, 0x05
     D7, 0x05EA, 0x0020, 0x05D7, 0x05E7, 0x05D9, 0x05E8, 0x05EA, | 
|  594             0x0020, 0x05DE, 0x05E6, 0x0022, 0x05D7, 0x0020, 0x05D1, 0x05E2, 0x05
     E7, 0x05D1, 0x05D5, 0x05EA, 0x0020, 0x05E2, 0x05D3, 0x05D5, |  595             0x0020, 0x05DE, 0x05E6, 0x0022, 0x05D7, 0x0020, 0x05D1, 0x05E2, 0x05
     E7, 0x05D1, 0x05D5, 0x05EA, 0x0020, 0x05E2, 0x05D3, 0x05D5, | 
|  595             0x05D9, 0x05D5, 0x05EA, 0x0020, 0x05D7, 0x05D9, 0x05D9, 0x05DC, 0x05
     D9, 0x0020, 0x05E6, 0x05D4, 0x0022, 0x05DC, 0x0020, 0x05DE, |  596             0x05D9, 0x05D5, 0x05EA, 0x0020, 0x05D7, 0x05D9, 0x05D9, 0x05DC, 0x05
     D9, 0x0020, 0x05E6, 0x05D4, 0x0022, 0x05DC, 0x0020, 0x05DE, | 
|  596             0x05DE, 0x05D1, 0x05E6, 0x05E2, 0x0020, 0x05E2, 0x05D5, 0x05E4, 0x05
     E8, 0x05EA, 0x0020, 0x05D9, 0x05E6, 0x05D5, 0x05E7, 0x05D4, |  597             0x05DE, 0x05D1, 0x05E6, 0x05E2, 0x0020, 0x05E2, 0x05D5, 0x05E4, 0x05
     E8, 0x05EA, 0x0020, 0x05D9, 0x05E6, 0x05D5, 0x05E7, 0x05D4, | 
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  669  |  670  | 
|  670     name  = ucsdet_getName(match, &status); |  671     name  = ucsdet_getName(match, &status); | 
|  671     if (strcmp(name, "IBM424_ltr") != 0) { |  672     if (strcmp(name, "IBM424_ltr") != 0) { | 
|  672         errln("Encoding detection failure for IBM424_ltr: got %s", name); |  673         errln("Encoding detection failure for IBM424_ltr: got %s", name); | 
|  673     } |  674     } | 
|  674  |  675  | 
|  675 bail: |  676 bail: | 
|  676     freeBytes(bytes); |  677     freeBytes(bytes); | 
|  677     freeBytes(bytes_r); |  678     freeBytes(bytes_r); | 
|  678     ucsdet_close(csd); |  679     ucsdet_close(csd); | 
 |  680 #endif | 
|  679 } |  681 } | 
|  680  |  682  | 
|  681 void CharsetDetectionTest::IBM420Test() |  683 void CharsetDetectionTest::IBM420Test() | 
|  682 { |  684 { | 
 |  685 #if !UCONFIG_ONLY_HTML_CONVERSION | 
|  683     UErrorCode status = U_ZERO_ERROR; |  686     UErrorCode status = U_ZERO_ERROR; | 
|  684      |  687      | 
|  685     static const UChar chars[] = { |  688     static const UChar chars[] = { | 
|  686         0x0648, 0x064F, 0x0636, 0x0639, 0x062A, 0x0020, 0x0648, 0x0646, 0x064F, 
     0x0641, 0x0630, 0x062A, 0x0020, 0x0628, 0x0631, 0x0627, |  689         0x0648, 0x064F, 0x0636, 0x0639, 0x062A, 0x0020, 0x0648, 0x0646, 0x064F, 
     0x0641, 0x0630, 0x062A, 0x0020, 0x0628, 0x0631, 0x0627, | 
|  687         0x0645, 0x062C, 0x0020, 0x062A, 0x0623, 0x0645, 0x064A, 0x0646, 0x0020, 
     0x0639, 0x062F, 0x064A, 0x062F, 0x0629, 0x0020, 0x0641, |  690         0x0645, 0x062C, 0x0020, 0x062A, 0x0623, 0x0645, 0x064A, 0x0646, 0x0020, 
     0x0639, 0x062F, 0x064A, 0x062F, 0x0629, 0x0020, 0x0641, | 
|  688         0x064A, 0x0020, 0x0645, 0x0624, 0x0633, 0x0633, 0x0629, 0x0020, 0x0627, 
     0x0644, 0x062A, 0x0623, 0x0645, 0x064A, 0x0646, 0x0020, |  691         0x064A, 0x0020, 0x0645, 0x0624, 0x0633, 0x0633, 0x0629, 0x0020, 0x0627, 
     0x0644, 0x062A, 0x0623, 0x0645, 0x064A, 0x0646, 0x0020, | 
|  689         0x0627, 0x0644, 0x0648, 0x0637, 0x0646, 0x064A, 0x002C, 0x0020, 0x0645, 
     0x0639, 0x0020, 0x0645, 0x0644, 0x0627, 0x0626, 0x0645, |  692         0x0627, 0x0644, 0x0648, 0x0637, 0x0646, 0x064A, 0x002C, 0x0020, 0x0645, 
     0x0639, 0x0020, 0x0645, 0x0644, 0x0627, 0x0626, 0x0645, | 
|  690         0x062A, 0x0647, 0x0627, 0x0020, 0x062F, 0x0627, 0x0626, 0x0645, 0x0627, 
     0x064B, 0x0020, 0x0644, 0x0644, 0x0627, 0x062D, 0x062A, |  693         0x062A, 0x0647, 0x0627, 0x0020, 0x062F, 0x0627, 0x0626, 0x0645, 0x0627, 
     0x064B, 0x0020, 0x0644, 0x0644, 0x0627, 0x062D, 0x062A, | 
|  691         0x064A, 0x0627, 0x062C, 0x0627, 0x062A, 0x0020, 0x0627, 0x0644, 0x0645, 
     0x062A, 0x063A, 0x064A, 0x0631, 0x0629, 0x0020, 0x0644, |  694         0x064A, 0x0627, 0x062C, 0x0627, 0x062A, 0x0020, 0x0627, 0x0644, 0x0645, 
     0x062A, 0x063A, 0x064A, 0x0631, 0x0629, 0x0020, 0x0644, | 
|  692         0x0644, 0x0645, 0x062C, 0x062A, 0x0645, 0x0639, 0x0020, 0x0648, 0x0644, 
     0x0644, 0x062F, 0x0648, 0x0644, 0x0629, 0x002E, 0x0020, |  695         0x0644, 0x0645, 0x062C, 0x062A, 0x0645, 0x0639, 0x0020, 0x0648, 0x0644, 
     0x0644, 0x062F, 0x0648, 0x0644, 0x0629, 0x002E, 0x0020, | 
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  757  |  760  | 
|  758     name  = ucsdet_getName(match, &status); |  761     name  = ucsdet_getName(match, &status); | 
|  759     if (strcmp(name, "IBM420_ltr") != 0) { |  762     if (strcmp(name, "IBM420_ltr") != 0) { | 
|  760         errln("Encoding detection failure for IBM420_ltr: got %s\n", name); |  763         errln("Encoding detection failure for IBM420_ltr: got %s\n", name); | 
|  761     } |  764     } | 
|  762  |  765  | 
|  763 bail: |  766 bail: | 
|  764     freeBytes(bytes); |  767     freeBytes(bytes); | 
|  765     freeBytes(bytes_r); |  768     freeBytes(bytes_r); | 
|  766     ucsdet_close(csd); |  769     ucsdet_close(csd); | 
 |  770 #endif | 
|  767 } |  771 } | 
|  768  |  772  | 
|  769  |  773  | 
|  770 void CharsetDetectionTest::Ticket6394Test() { |  774 void CharsetDetectionTest::Ticket6394Test() { | 
|  771 #if !UCONFIG_NO_CONVERSION |  775 #if !UCONFIG_NO_CONVERSION | 
|  772     const char charText[] =  "Here is some random English text that should be de
     tected as ISO-8859-1." |  776     const char charText[] =  "Here is some random English text that should be de
     tected as ISO-8859-1." | 
|  773                              "Ticket 6394 claims that ISO-8859-1 will appear in 
     the array of detected " |  777                              "Ticket 6394 claims that ISO-8859-1 will appear in 
     the array of detected " | 
|  774                              "encodings more than once.  The hop through Unicode
     String is for platforms "  |  778                              "encodings more than once.  The hop through Unicode
     String is for platforms "  | 
|  775                              "where this char * string is be EBCDIC and needs co
     nversion to Latin1."; |  779                              "where this char * string is be EBCDIC and needs co
     nversion to Latin1."; | 
|  776     char latin1Text[sizeof(charText)]; |  780     char latin1Text[sizeof(charText)]; | 
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  848     name1 = ucsdet_getName(match1, &status); |  852     name1 = ucsdet_getName(match1, &status); | 
|  849     TEST_ASSERT_SUCCESS(status); |  853     TEST_ASSERT_SUCCESS(status); | 
|  850     TEST_ASSERT(strcmp(name1, "windows-1252")==0); |  854     TEST_ASSERT(strcmp(name1, "windows-1252")==0); | 
|  851  |  855  | 
|  852     ucsdet_close(csd1); |  856     ucsdet_close(csd1); | 
|  853     ucsdet_close(csd2); |  857     ucsdet_close(csd2); | 
|  854     freeBytes(bISO); |  858     freeBytes(bISO); | 
|  855     freeBytes(bWindows); |  859     freeBytes(bWindows); | 
|  856 #endif |  860 #endif | 
|  857 } |  861 } | 
| OLD | NEW |