From 1a68b33110c60a564f29fb0daab0a0bae5d02e56 Mon Sep 17 00:00:00 2001 From: George Rhoten Date: Fri, 11 Aug 2000 18:58:51 +0000 Subject: [PATCH] ICU-535 fixed some compiler warnings X-SVN-Rev: 2197 --- icu4c/source/test/cintltst/nccbtst.c | 1636 +++++++++++++------------- icu4c/source/test/cintltst/nccbtst.h | 8 +- 2 files changed, 824 insertions(+), 820 deletions(-) diff --git a/icu4c/source/test/cintltst/nccbtst.c b/icu4c/source/test/cintltst/nccbtst.c index 31ac888bc67..f037b907d7a 100644 --- a/icu4c/source/test/cintltst/nccbtst.c +++ b/icu4c/source/test/cintltst/nccbtst.c @@ -7,7 +7,7 @@ * File NCCBTST.C * * Modification History: -* Name Description +* Name Description * Madhu Katragadda 7/21/1999 Testing error callback routines ************************************************************************************** */ @@ -31,205 +31,209 @@ static int32_t gInBufferSize = 0; static int32_t gOutBufferSize = 0; static char gNuConvTestName[1024]; -void printSeq(const char* a, int len) +void printSeq(const uint8_t* a, int len) { - int i=0; - log_verbose("\n{"); - while (i ibm-949 with skip did not match.\n"); - if(!testConvertFromUnicode(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]), - expskipIBM_943, sizeof(expskipIBM_943), "ibm-943", - (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SKIP, toIBM943Offsskip, NULL, 0 )) - log_err("u-> ibm-943 with skip did not match.\n"); - if(!testConvertFromUnicode(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]), - expskipIBM_930, sizeof(expskipIBM_930), "ibm-930", - (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SKIP, toIBM930Offsskip , NULL, 0)) - log_err("u-> ibm-930 with skip did not match.\n"); + gInBufferSize = inputsize; + gOutBufferSize = outputsize; + /*From Unicode*/ + if(!testConvertFromUnicode(sampleText, sizeof(sampleText)/sizeof(sampleText[0]), + expskipIBM_949, sizeof(expskipIBM_949), "ibm-949", + (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SKIP, toIBM949Offsskip, NULL, 0 )) + log_err("u-> ibm-949 with skip did not match.\n"); + if(!testConvertFromUnicode(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]), + expskipIBM_943, sizeof(expskipIBM_943), "ibm-943", + (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SKIP, toIBM943Offsskip, NULL, 0 )) + log_err("u-> ibm-943 with skip did not match.\n"); + if(!testConvertFromUnicode(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]), + expskipIBM_930, sizeof(expskipIBM_930), "ibm-930", + (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SKIP, toIBM930Offsskip , NULL, 0)) + log_err("u-> ibm-930 with skip did not match.\n"); log_verbose("Testing fromUnicode with UCNV_FROM_U_CALLBACK_SKIP \n"); { UChar inputTest[] = { 0x0061, 0xd801, 0xdc01, 0xd801, 0x0061 }; - const char toIBM943[]= { (char)0x61, (char)0x61 }; + const uint8_t toIBM943[]= { 0x61, 0x61 }; int32_t offset[]= {0, 4}; /* EUC_JP*/ UChar euc_jp_inputText[]={ 0x0061, 0x4edd, 0x5bec, 0xd801, 0xdc01, 0xd801, 0x0061, 0x00a2 }; - const char to_euc_jp[]={ (char)0x61, (char)0xa1, (char)0xb8, (char)0x8f, (char)0xf4, (char)0xae, - (char)0x61, (char)0x8e, (char)0xe0, + const uint8_t to_euc_jp[]={ 0x61, 0xa1, 0xb8, 0x8f, 0xf4, 0xae, + 0x61, 0x8e, 0xe0, }; int32_t fromEUC_JPOffs [] ={ 0, 1, 1, 2, 2, 2, 6, 7, 7}; /*EUC_TW*/ UChar euc_tw_inputText[]={ 0x0061, 0x2295, 0x5BF2, 0xd801, 0xdc01, 0xd801, 0x0061, 0x8706, 0x8a, }; - const char to_euc_tw[]={ - (char)0x61, (char)0xa2, (char)0xd3, (char)0x8e, (char)0xa2, (char)0xdc, (char)0xe5, - (char)0x61, (char)0xe6, (char)0xca, (char)0x8a, + const uint8_t to_euc_tw[]={ + 0x61, 0xa2, 0xd3, 0x8e, 0xa2, 0xdc, 0xe5, + 0x61, 0xe6, 0xca, 0x8a, }; int32_t from_euc_twOffs [] ={ 0, 1, 1, 2, 2, 2, 2, 6, 7, 7, 8,}; if(!testConvertFromUnicode(inputTest, sizeof(inputTest)/sizeof(inputTest[0]), - toIBM943, sizeof(toIBM943), "ibm-943", - (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SKIP, offset, NULL, 0 )) - log_err("u-> ibm-943 with skip did not match.\n"); + toIBM943, sizeof(toIBM943), "ibm-943", + (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SKIP, offset, NULL, 0 )) + log_err("u-> ibm-943 with skip did not match.\n"); if(!testConvertFromUnicode(euc_jp_inputText, sizeof(euc_jp_inputText)/sizeof(euc_jp_inputText[0]), - to_euc_jp, sizeof(to_euc_jp), "euc-jp", - (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SKIP, fromEUC_JPOffs, NULL, 0 )) - log_err("u-> euc-jp with skip did not match.\n"); + to_euc_jp, sizeof(to_euc_jp), "euc-jp", + (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SKIP, fromEUC_JPOffs, NULL, 0 )) + log_err("u-> euc-jp with skip did not match.\n"); if(!testConvertFromUnicode(euc_tw_inputText, sizeof(euc_tw_inputText)/sizeof(euc_tw_inputText[0]), - to_euc_tw, sizeof(to_euc_tw), "euc-tw", - (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SKIP, from_euc_twOffs, NULL, 0 )) - log_err("u-> euc-tw with skip did not match.\n"); + to_euc_tw, sizeof(to_euc_tw), "euc-tw", + (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SKIP, from_euc_twOffs, NULL, 0 )) + log_err("u-> euc-tw with skip did not match.\n"); } - /*to Unicode*/ - if(!testConvertToUnicode(expskipIBM_949, sizeof(expskipIBM_949), - IBM_949skiptoUnicode, sizeof(IBM_949skiptoUnicode)/sizeof(IBM_949skiptoUnicode),"ibm-949", - (UConverterToUCallback)UCNV_TO_U_CALLBACK_SKIP, fromIBM949Offs, NULL, 0 )) - log_err("ibm-949->u with skip did not match.\n"); + /*to Unicode*/ + if(!testConvertToUnicode(expskipIBM_949, sizeof(expskipIBM_949), + IBM_949skiptoUnicode, sizeof(IBM_949skiptoUnicode)/sizeof(IBM_949skiptoUnicode),"ibm-949", + (UConverterToUCallback)UCNV_TO_U_CALLBACK_SKIP, fromIBM949Offs, NULL, 0 )) + log_err("ibm-949->u with skip did not match.\n"); if(!testConvertToUnicode(expskipIBM_943, sizeof(expskipIBM_943), - IBM_943skiptoUnicode, sizeof(IBM_943skiptoUnicode)/sizeof(IBM_943skiptoUnicode[0]),"ibm-943", - (UConverterToUCallback)UCNV_TO_U_CALLBACK_SKIP, fromIBM943Offs, NULL, 0 )) - log_err("ibm-943->u with skip did not match.\n"); - - if(!testConvertToUnicode(expskipIBM_930, sizeof(expskipIBM_930), - IBM_930skiptoUnicode, sizeof(IBM_930skiptoUnicode)/sizeof(IBM_930skiptoUnicode[0]),"ibm-930", - (UConverterToUCallback)UCNV_TO_U_CALLBACK_SKIP, fromIBM930Offs, NULL, 0 )) - log_err("ibm-930->u with skip did not match.\n"); + IBM_943skiptoUnicode, sizeof(IBM_943skiptoUnicode)/sizeof(IBM_943skiptoUnicode[0]),"ibm-943", + (UConverterToUCallback)UCNV_TO_U_CALLBACK_SKIP, fromIBM943Offs, NULL, 0 )) + log_err("ibm-943->u with skip did not match.\n"); - log_verbose("Testing toUnicode with UCNV_TO_U_CALLBACK_SKIP \n"); + if(!testConvertToUnicode(expskipIBM_930, sizeof(expskipIBM_930), + IBM_930skiptoUnicode, sizeof(IBM_930skiptoUnicode)/sizeof(IBM_930skiptoUnicode[0]),"ibm-930", + (UConverterToUCallback)UCNV_TO_U_CALLBACK_SKIP, fromIBM930Offs, NULL, 0 )) + log_err("ibm-930->u with skip did not match.\n"); + + log_verbose("Testing toUnicode with UCNV_TO_U_CALLBACK_SKIP \n"); { - const char sampleTxtEBCIDIC_STATEFUL [] ={ - (char)0x0e, (char)0x5d, (char)0x5f , (char)0x41, (char)0x79, (char)0x41, (char)0x44 + const uint8_t sampleTxtEBCIDIC_STATEFUL [] ={ + 0x0e, 0x5d, 0x5f , 0x41, 0x79, 0x41, 0x44 }; UChar EBCIDIC_STATEFUL_toUnicode[] ={ 0x6d63, 0x03b4 }; @@ -237,196 +241,196 @@ void TestSkip(int32_t inputsize, int32_t outputsize) /* euc-jp*/ - const char sampleTxt_euc_jp[]={ (char)0x61, (char)0xa1, (char)0xb8, (char)0x8f, (char)0xf4, (char)0xae, - (char)0x8f, (char)0xda, (char)0xa1, /*unassigned*/ - (char)0x8e, (char)0xe0, + const uint8_t sampleTxt_euc_jp[]={ 0x61, 0xa1, 0xb8, 0x8f, 0xf4, 0xae, + 0x8f, 0xda, 0xa1, /*unassigned*/ + 0x8e, 0xe0, }; UChar euc_jptoUnicode[]={ 0x0061, 0x4edd, 0x5bec, 0x00a2}; int32_t from_euc_jpOffs [] ={ 0, 1, 3, 9}; /*EUC_TW*/ - const char sampleTxt_euc_tw[]={ (char)0x61, (char)0xa2, (char)0xd3, (char)0x8e, (char)0xa2, (char)0xdc, (char)0xe5, - (char)0x8e, (char)0xaa, (char)0xbb, (char)0xcc,/*unassigned*/ - (char)0xe6, (char)0xca, (char)0x8a, + const uint8_t sampleTxt_euc_tw[]={ 0x61, 0xa2, 0xd3, 0x8e, 0xa2, 0xdc, 0xe5, + 0x8e, 0xaa, 0xbb, 0xcc,/*unassigned*/ + 0xe6, 0xca, 0x8a, }; UChar euc_twtoUnicode[]={ 0x0061, 0x2295, 0x5BF2, 0x8706, 0x8a, }; int32_t from_euc_twOffs [] ={ 0, 1, 3, 11, 13}; /*LMBCS*/ - const char sampleTxtLMBCS[]={ (char)0x12, (char)0xc9, (char)0x50, - (char)0x12, (char)0x92, (char)0xa0, /*unassigned*/ - (char)0x12, (char)0x92, (char)0xA1, + const uint8_t sampleTxtLMBCS[]={ 0x12, 0xc9, 0x50, + 0x12, 0x92, 0xa0, /*unassigned*/ + 0x12, 0x92, 0xA1, }; UChar LMBCSToUnicode[]={ 0x4e2e, 0xe5c4}; int32_t fromLMBCS[] = {0, 6}; if(!testConvertToUnicode(sampleTxtEBCIDIC_STATEFUL, sizeof(sampleTxtEBCIDIC_STATEFUL), - EBCIDIC_STATEFUL_toUnicode, sizeof(EBCIDIC_STATEFUL_toUnicode)/sizeof(EBCIDIC_STATEFUL_toUnicode[0]),"ibm-930", - (UConverterToUCallback)UCNV_TO_U_CALLBACK_SKIP, from_EBCIDIC_STATEFULOffsets, NULL, 0 )) - log_err("EBCIDIC_STATEFUL->u with skip did not match.\n"); + EBCIDIC_STATEFUL_toUnicode, sizeof(EBCIDIC_STATEFUL_toUnicode)/sizeof(EBCIDIC_STATEFUL_toUnicode[0]),"ibm-930", + (UConverterToUCallback)UCNV_TO_U_CALLBACK_SKIP, from_EBCIDIC_STATEFULOffsets, NULL, 0 )) + log_err("EBCIDIC_STATEFUL->u with skip did not match.\n"); if(!testConvertToUnicode(sampleTxt_euc_jp, sizeof(sampleTxt_euc_jp), - euc_jptoUnicode, sizeof(euc_jptoUnicode)/sizeof(euc_jptoUnicode[0]),"euc-jp", - (UConverterToUCallback)UCNV_TO_U_CALLBACK_SKIP, from_euc_jpOffs , NULL, 0)) - log_err("euc-jp->u with skip did not match.\n"); + euc_jptoUnicode, sizeof(euc_jptoUnicode)/sizeof(euc_jptoUnicode[0]),"euc-jp", + (UConverterToUCallback)UCNV_TO_U_CALLBACK_SKIP, from_euc_jpOffs , NULL, 0)) + log_err("euc-jp->u with skip did not match.\n"); + - if(!testConvertToUnicode(sampleTxt_euc_tw, sizeof(sampleTxt_euc_tw), - euc_twtoUnicode, sizeof(euc_twtoUnicode)/sizeof(euc_twtoUnicode[0]),"euc-tw", - (UConverterToUCallback)UCNV_TO_U_CALLBACK_SKIP, from_euc_twOffs , NULL, 0)) - log_err("euc-tw->u with skip did not match.\n"); + euc_twtoUnicode, sizeof(euc_twtoUnicode)/sizeof(euc_twtoUnicode[0]),"euc-tw", + (UConverterToUCallback)UCNV_TO_U_CALLBACK_SKIP, from_euc_twOffs , NULL, 0)) + log_err("euc-tw->u with skip did not match.\n"); if(/* broken for icu 1.6, do not test */uprv_strcmp("1.6", U_ICU_VERSION) != 0 && !testConvertToUnicode(sampleTxtLMBCS, sizeof(sampleTxtLMBCS), - LMBCSToUnicode, sizeof(LMBCSToUnicode)/sizeof(LMBCSToUnicode[0]),"LMBCS-1", - (UConverterToUCallback)UCNV_TO_U_CALLBACK_SKIP, fromLMBCS , NULL, 0)) - log_err("LMBCS->u with skip did not match.\n"); + LMBCSToUnicode, sizeof(LMBCSToUnicode)/sizeof(LMBCSToUnicode[0]),"LMBCS-1", + (UConverterToUCallback)UCNV_TO_U_CALLBACK_SKIP, fromLMBCS , NULL, 0)) + log_err("LMBCS->u with skip did not match.\n"); } - log_verbose("Testing to Unicode for UTF-8 with UCNV_TO_U_CALLBACK_SKIP \n"); + log_verbose("Testing to Unicode for UTF-8 with UCNV_TO_U_CALLBACK_SKIP \n"); { - const char sampleText1[] = { (char)0x31, (char)0xe4, (char)0xba, (char)0x8c, - (char)0xe0, (char)0x80, (char)0x61,}; + const uint8_t sampleText1[] = { 0x31, 0xe4, 0xba, 0x8c, + 0xe0, 0x80, 0x61,}; UChar expected1[] = { 0x0031, 0x4e8c, 0x0061}; int32_t offsets1[] = { 0x0000, 0x0001, 0x0006}; if(!testConvertToUnicode(sampleText1, sizeof(sampleText1), - expected1, sizeof(expected1)/sizeof(expected1[0]),"utf8", - (UConverterToUCallback)UCNV_TO_U_CALLBACK_SKIP, offsets1, NULL, 0 )) - log_err("utf8->u with skip did not match.\n");; + expected1, sizeof(expected1)/sizeof(expected1[0]),"utf8", + (UConverterToUCallback)UCNV_TO_U_CALLBACK_SKIP, offsets1, NULL, 0 )) + log_err("utf8->u with skip did not match.\n");; } } void TestStop(int32_t inputsize, int32_t outputsize) { - UChar sampleText[] = { 0x0000, 0xAC00, 0xAC01, 0xEF67, 0xD700 }; - UChar sampleText2[] = { 0x6D63, 0x6D64, 0x6D65, 0x6D66 }; + UChar sampleText[] = { 0x0000, 0xAC00, 0xAC01, 0xEF67, 0xD700 }; + UChar sampleText2[] = { 0x6D63, 0x6D64, 0x6D65, 0x6D66 }; - const char expstopIBM_949[]= { - (char)0x00, (char)0xb0, (char)0xa1, (char)0xb0, (char)0xa2}; - - const char expstopIBM_943[] = { - (char)0x9f, (char)0xaf, (char)0x9f, (char)0xb1}; - - const char expstopIBM_930[] = { - (char)0x0e, (char)0x5d, (char)0x5f, (char)0x5d, (char)0x63}; - - UChar IBM_949stoptoUnicode[]= {0x0000, 0xAC00, 0xAC01}; - UChar IBM_943stoptoUnicode[]= { 0x6D63, 0x6D64}; - UChar IBM_930stoptoUnicode[]= { 0x6D63, 0x6D64}; + const uint8_t expstopIBM_949[]= { + 0x00, 0xb0, 0xa1, 0xb0, 0xa2}; + + const uint8_t expstopIBM_943[] = { + 0x9f, 0xaf, 0x9f, 0xb1}; + + const uint8_t expstopIBM_930[] = { + 0x0e, 0x5d, 0x5f, 0x5d, 0x63}; + + UChar IBM_949stoptoUnicode[]= {0x0000, 0xAC00, 0xAC01}; + UChar IBM_943stoptoUnicode[]= { 0x6D63, 0x6D64}; + UChar IBM_930stoptoUnicode[]= { 0x6D63, 0x6D64}; - int32_t toIBM949Offsstop [] = { 0, 1, 1, 2, 2}; - int32_t toIBM943Offsstop [] = { 0, 0, 1, 1}; - int32_t toIBM930Offsstop [] = { 0, 0, 0, 1, 1}; - + int32_t toIBM949Offsstop [] = { 0, 1, 1, 2, 2}; + int32_t toIBM943Offsstop [] = { 0, 0, 1, 1}; + int32_t toIBM930Offsstop [] = { 0, 0, 0, 1, 1}; + int32_t fromIBM949Offs [] = { 0, 1, 3}; - int32_t fromIBM943Offs [] = { 0, 2}; - int32_t fromIBM930Offs [] = { 1, 3}; + int32_t fromIBM943Offs [] = { 0, 2}; + int32_t fromIBM930Offs [] = { 1, 3}; + + gInBufferSize = inputsize; + gOutBufferSize = outputsize; + /*From Unicode*/ + if(!testConvertFromUnicode(sampleText, sizeof(sampleText)/sizeof(sampleText[0]), + expstopIBM_949, sizeof(expstopIBM_949), "ibm-949", + (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_STOP, toIBM949Offsstop, NULL, 0 )) + log_err("u-> ibm-949 with stop did not match.\n"); + if(!testConvertFromUnicode(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]), + expstopIBM_943, sizeof(expstopIBM_943), "ibm-943", + (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_STOP, toIBM943Offsstop , NULL, 0)) + log_err("u-> ibm-943 with stop did not match.\n"); + if(!testConvertFromUnicode(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]), + expstopIBM_930, sizeof(expstopIBM_930), "ibm-930", + (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_STOP, toIBM930Offsstop, NULL, 0 )) + log_err("u-> ibm-930 with stop did not match.\n"); - gInBufferSize = inputsize; - gOutBufferSize = outputsize; - /*From Unicode*/ - if(!testConvertFromUnicode(sampleText, sizeof(sampleText)/sizeof(sampleText[0]), - expstopIBM_949, sizeof(expstopIBM_949), "ibm-949", - (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_STOP, toIBM949Offsstop, NULL, 0 )) - log_err("u-> ibm-949 with stop did not match.\n"); - if(!testConvertFromUnicode(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]), - expstopIBM_943, sizeof(expstopIBM_943), "ibm-943", - (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_STOP, toIBM943Offsstop , NULL, 0)) - log_err("u-> ibm-943 with stop did not match.\n"); - if(!testConvertFromUnicode(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]), - expstopIBM_930, sizeof(expstopIBM_930), "ibm-930", - (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_STOP, toIBM930Offsstop, NULL, 0 )) - log_err("u-> ibm-930 with stop did not match.\n"); - log_verbose("Testing fromUnicode with UCNV_FROM_U_CALLBACK_STOP \n"); { UChar inputTest[] = { 0x0061, 0xd801, 0xdc01, 0xd801, 0x0061 }; - const char toIBM943[]= { (char)0x61,}; + const uint8_t toIBM943[]= { 0x61,}; int32_t offset[]= {0,} ; /*EUC_JP*/ UChar euc_jp_inputText[]={ 0x0061, 0x4edd, 0x5bec, 0xd801, 0xdc01, 0xd801, 0x0061, 0x00a2 }; - const char to_euc_jp[]={ (char)0x61, (char)0xa1, (char)0xb8, (char)0x8f, (char)0xf4, (char)0xae,}; + const uint8_t to_euc_jp[]={ 0x61, 0xa1, 0xb8, 0x8f, 0xf4, 0xae,}; int32_t fromEUC_JPOffs [] ={ 0, 1, 1, 2, 2, 2,}; /*EUC_TW*/ UChar euc_tw_inputText[]={ 0x0061, 0x2295, 0x5BF2, 0xd801, 0xdc01, 0xd801, 0x0061, 0x8706, 0x8a, }; - const char to_euc_tw[]={ - (char)0x61, (char)0xa2, (char)0xd3, (char)0x8e, (char)0xa2, (char)0xdc, (char)0xe5,}; + const uint8_t to_euc_tw[]={ + 0x61, 0xa2, 0xd3, 0x8e, 0xa2, 0xdc, 0xe5,}; int32_t from_euc_twOffs [] ={ 0, 1, 1, 2, 2, 2, 2,}; if(!testConvertFromUnicode(inputTest, sizeof(inputTest)/sizeof(inputTest[0]), - toIBM943, sizeof(toIBM943), "ibm-943", - (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_STOP, offset, NULL, 0 )) - log_err("u-> ibm-943 with stop did not match.\n"); + toIBM943, sizeof(toIBM943), "ibm-943", + (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_STOP, offset, NULL, 0 )) + log_err("u-> ibm-943 with stop did not match.\n"); if(!testConvertFromUnicode(euc_jp_inputText, sizeof(euc_jp_inputText)/sizeof(euc_jp_inputText[0]), - to_euc_jp, sizeof(to_euc_jp), "euc-jp", - (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_STOP, fromEUC_JPOffs, NULL, 0 )) - log_err("u-> euc-jp with stop did not match.\n"); + to_euc_jp, sizeof(to_euc_jp), "euc-jp", + (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_STOP, fromEUC_JPOffs, NULL, 0 )) + log_err("u-> euc-jp with stop did not match.\n"); if(!testConvertFromUnicode(euc_tw_inputText, sizeof(euc_tw_inputText)/sizeof(euc_tw_inputText[0]), - to_euc_tw, sizeof(to_euc_tw), "euc-tw", - (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_STOP, from_euc_twOffs, NULL, 0 )) - log_err("u-> euc-tw with stop did not match.\n"); - + to_euc_tw, sizeof(to_euc_tw), "euc-tw", + (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_STOP, from_euc_twOffs, NULL, 0 )) + log_err("u-> euc-tw with stop did not match.\n"); + } log_verbose("Testing fromUnicode for UTF-8 with UCNV_FROM_U_CALLBACK_STOP \n"); { const UChar testinput[]={ 0x20ac, 0xd801, 0xdc01, 0xdc01, 0xd801, 0xffff, 0x0061,}; - const char expectedUTF8[]= { (char)0xe2, (char)0x82, (char)0xac, - (char)0xf0, (char)0x90, (char)0x90, (char)0x81, - (char)0xed, (char)0xb0, (char)0x81, (char)0xed, (char)0xa0, (char)0x81, - (char)0xef, (char)0xbf, (char)0xbf, (char)0x61, + const uint8_t expectedUTF8[]= { 0xe2, 0x82, 0xac, + 0xf0, 0x90, 0x90, 0x81, + 0xed, 0xb0, 0x81, 0xed, 0xa0, 0x81, + 0xef, 0xbf, 0xbf, 0x61, }; int32_t offsets[]={ 0, 0, 0, 1, 1, 1, 1, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6 }; if(!testConvertFromUnicode(testinput, sizeof(testinput)/sizeof(testinput[0]), - expectedUTF8, sizeof(expectedUTF8), "utf8", - (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_STOP, offsets, NULL, 0 )) - log_err("u-> utf8 with stop did not match.\n"); + expectedUTF8, sizeof(expectedUTF8), "utf8", + (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_STOP, offsets, NULL, 0 )) + log_err("u-> utf8 with stop did not match.\n"); } - /*to Unicode*/ - if(!testConvertToUnicode(expstopIBM_949, sizeof(expstopIBM_949), - IBM_949stoptoUnicode, sizeof(IBM_949stoptoUnicode)/sizeof(IBM_949stoptoUnicode[0]),"ibm-949", - (UConverterToUCallback)UCNV_TO_U_CALLBACK_STOP, fromIBM949Offs, NULL, 0 )) - log_err("ibm-949->u with stop did not match.\n"); + /*to Unicode*/ + if(!testConvertToUnicode(expstopIBM_949, sizeof(expstopIBM_949), + IBM_949stoptoUnicode, sizeof(IBM_949stoptoUnicode)/sizeof(IBM_949stoptoUnicode[0]),"ibm-949", + (UConverterToUCallback)UCNV_TO_U_CALLBACK_STOP, fromIBM949Offs, NULL, 0 )) + log_err("ibm-949->u with stop did not match.\n"); if(!testConvertToUnicode(expstopIBM_943, sizeof(expstopIBM_943), - IBM_943stoptoUnicode, sizeof(IBM_943stoptoUnicode)/sizeof(IBM_943stoptoUnicode[0]),"ibm-943", - (UConverterToUCallback)UCNV_TO_U_CALLBACK_STOP, fromIBM943Offs, NULL, 0 )) - log_err("ibm-943->u with stop did not match.\n"); + IBM_943stoptoUnicode, sizeof(IBM_943stoptoUnicode)/sizeof(IBM_943stoptoUnicode[0]),"ibm-943", + (UConverterToUCallback)UCNV_TO_U_CALLBACK_STOP, fromIBM943Offs, NULL, 0 )) + log_err("ibm-943->u with stop did not match.\n"); if(!testConvertToUnicode(expstopIBM_930, sizeof(expstopIBM_930), - IBM_930stoptoUnicode, sizeof(IBM_930stoptoUnicode)/sizeof(IBM_930stoptoUnicode[0]),"ibm-930", - (UConverterToUCallback)UCNV_TO_U_CALLBACK_STOP, fromIBM930Offs, NULL, 0 )) - log_err("ibm-930->u with stop did not match.\n"); + IBM_930stoptoUnicode, sizeof(IBM_930stoptoUnicode)/sizeof(IBM_930stoptoUnicode[0]),"ibm-930", + (UConverterToUCallback)UCNV_TO_U_CALLBACK_STOP, fromIBM930Offs, NULL, 0 )) + log_err("ibm-930->u with stop did not match.\n"); - log_verbose("Testing toUnicode with UCNV_TO_U_CALLBACK_STOP \n"); + log_verbose("Testing toUnicode with UCNV_TO_U_CALLBACK_STOP \n"); { - const char sampleTxtEBCIDIC_STATEFUL [] ={ - (char)0x0e, (char)0x5d, (char)0x5f , (char)0x41, (char)0x79, (char)0x41, (char)0x44 + const uint8_t sampleTxtEBCIDIC_STATEFUL [] ={ + 0x0e, 0x5d, 0x5f , 0x41, 0x79, 0x41, 0x44 }; UChar EBCIDIC_STATEFUL_toUnicode[] ={ 0x6d63 }; int32_t from_EBCIDIC_STATEFULOffsets []={ 1}; /*EUC-JP*/ - const char sampleTxt_euc_jp[]={ (char)0x61, (char)0xa1, (char)0xb8, (char)0x8f, (char)0xf4, (char)0xae, - (char)0x8f, (char)0xda, (char)0xa1, /*unassigned*/ - (char)0x8e, (char)0xe0, + const uint8_t sampleTxt_euc_jp[]={ 0x61, 0xa1, 0xb8, 0x8f, 0xf4, 0xae, + 0x8f, 0xda, 0xa1, /*unassigned*/ + 0x8e, 0xe0, }; UChar euc_jptoUnicode[]={ 0x0061, 0x4edd, 0x5bec}; int32_t from_euc_jpOffs [] ={ 0, 1, 3}; /*EUC_TW*/ - const char sampleTxt_euc_tw[]={ (char)0x61, (char)0xa2, (char)0xd3, (char)0x8e, (char)0xa2, (char)0xdc, (char)0xe5, - (char)0x8e, (char)0xaa, (char)0xbb, (char)0xcc,/*unassigned*/ - (char)0xe6, (char)0xca, (char)0x8a, + const uint8_t sampleTxt_euc_tw[]={ 0x61, 0xa2, 0xd3, 0x8e, 0xa2, 0xdc, 0xe5, + 0x8e, 0xaa, 0xbb, 0xcc,/*unassigned*/ + 0xe6, 0xca, 0x8a, }; UChar euc_twtoUnicode[]={ 0x0061, 0x2295, 0x5BF2}; int32_t from_euc_twOffs [] ={ 0, 1, 3}; @@ -434,138 +438,138 @@ void TestStop(int32_t inputsize, int32_t outputsize) if(!testConvertToUnicode(sampleTxtEBCIDIC_STATEFUL, sizeof(sampleTxtEBCIDIC_STATEFUL), - EBCIDIC_STATEFUL_toUnicode, sizeof(EBCIDIC_STATEFUL_toUnicode)/sizeof(EBCIDIC_STATEFUL_toUnicode[0]),"ibm-930", - (UConverterToUCallback)UCNV_TO_U_CALLBACK_STOP, from_EBCIDIC_STATEFULOffsets, NULL, 0 )) - log_err("EBCIDIC_STATEFUL->u with stop did not match.\n"); + EBCIDIC_STATEFUL_toUnicode, sizeof(EBCIDIC_STATEFUL_toUnicode)/sizeof(EBCIDIC_STATEFUL_toUnicode[0]),"ibm-930", + (UConverterToUCallback)UCNV_TO_U_CALLBACK_STOP, from_EBCIDIC_STATEFULOffsets, NULL, 0 )) + log_err("EBCIDIC_STATEFUL->u with stop did not match.\n"); if(!testConvertToUnicode(sampleTxt_euc_jp, sizeof(sampleTxt_euc_jp), - euc_jptoUnicode, sizeof(euc_jptoUnicode)/sizeof(euc_jptoUnicode[0]),"euc-jp", - (UConverterToUCallback)UCNV_TO_U_CALLBACK_STOP, from_euc_jpOffs , NULL, 0)) - log_err("euc-jp->u with stop did not match.\n"); + euc_jptoUnicode, sizeof(euc_jptoUnicode)/sizeof(euc_jptoUnicode[0]),"euc-jp", + (UConverterToUCallback)UCNV_TO_U_CALLBACK_STOP, from_euc_jpOffs , NULL, 0)) + log_err("euc-jp->u with stop did not match.\n"); if(!testConvertToUnicode(sampleTxt_euc_tw, sizeof(sampleTxt_euc_tw), - euc_twtoUnicode, sizeof(euc_twtoUnicode)/sizeof(euc_twtoUnicode[0]),"euc-tw", - (UConverterToUCallback)UCNV_TO_U_CALLBACK_STOP, from_euc_jpOffs, NULL, 0 )) - log_err("euc-tw->u with stop did not match.\n"); + euc_twtoUnicode, sizeof(euc_twtoUnicode)/sizeof(euc_twtoUnicode[0]),"euc-tw", + (UConverterToUCallback)UCNV_TO_U_CALLBACK_STOP, from_euc_jpOffs, NULL, 0 )) + log_err("euc-tw->u with stop did not match.\n"); } log_verbose("Testing fromUnicode for UTF-8 with UCNV_TO_U_CALLBACK_STOP \n"); { - const char sampleText1[] = { (char)0x31, (char)0xe4, (char)0xba, (char)0x8c, - (char)0xe0, (char)0x80, (char)0x61,}; + const uint8_t sampleText1[] = { 0x31, 0xe4, 0xba, 0x8c, + 0xe0, 0x80, 0x61,}; UChar expected1[] = { 0x0031, 0x4e8c,}; int32_t offsets1[] = { 0x0000, 0x0001}; if(!testConvertToUnicode(sampleText1, sizeof(sampleText1), - expected1, sizeof(expected1)/sizeof(expected1[0]),"utf8", - (UConverterToUCallback)UCNV_TO_U_CALLBACK_STOP, offsets1, NULL, 0 )) - log_err("utf8->u with stop did not match.\n");; + expected1, sizeof(expected1)/sizeof(expected1[0]),"utf8", + (UConverterToUCallback)UCNV_TO_U_CALLBACK_STOP, offsets1, NULL, 0 )) + log_err("utf8->u with stop did not match.\n");; } } void TestSub(int32_t inputsize, int32_t outputsize) { - UChar sampleText[] = { 0x0000, 0xAC00, 0xAC01, 0xEF67, 0xD700 }; - UChar sampleText2[]= { 0x6D63, 0x6D64, 0x6D65, 0x6D66 }; + UChar sampleText[] = { 0x0000, 0xAC00, 0xAC01, 0xEF67, 0xD700 }; + UChar sampleText2[]= { 0x6D63, 0x6D64, 0x6D65, 0x6D66 }; - const char expsubIBM_949[] = - { (char)0x00, (char)0xb0, (char)0xa1, (char)0xb0, (char)0xa2, (char)0xaf, (char)0xfe, (char)0xc8, (char)0xd3 }; - - const char expsubIBM_943[] = { - (char)0x9f, (char)0xaf, (char)0x9f, (char)0xb1, (char)0xfc, (char)0xfc, (char)0x89, (char)0x59 }; - - const char expsubIBM_930[] = { - (char)0x0e, (char)0x5d, (char)0x5f, (char)0x5d, (char)0x63, (char)0xfe, (char)0xfe, (char)0x46, (char)0x6b }; - - UChar IBM_949subtoUnicode[]= {0x0000, 0xAC00, 0xAC01, 0xfffd, 0xD700 }; + const uint8_t expsubIBM_949[] = + { 0x00, 0xb0, 0xa1, 0xb0, 0xa2, 0xaf, 0xfe, 0xc8, 0xd3 }; + + const uint8_t expsubIBM_943[] = { + 0x9f, 0xaf, 0x9f, 0xb1, 0xfc, 0xfc, 0x89, 0x59 }; + + const uint8_t expsubIBM_930[] = { + 0x0e, 0x5d, 0x5f, 0x5d, 0x63, 0xfe, 0xfe, 0x46, 0x6b }; + + UChar IBM_949subtoUnicode[]= {0x0000, 0xAC00, 0xAC01, 0xfffd, 0xD700 }; UChar IBM_943subtoUnicode[]= {0x6D63, 0x6D64, 0xfffd, 0x6D66 }; - UChar IBM_930subtoUnicode[]= {0x6D63, 0x6D64, 0xfffd, 0x6D66 }; - + UChar IBM_930subtoUnicode[]= {0x6D63, 0x6D64, 0xfffd, 0x6D66 }; + int32_t toIBM949Offssub [] ={ 0, 1, 1, 2, 2, 3, 3, 4, 4}; int32_t toIBM943Offssub [] ={ 0, 0, 1, 1, 2, 2, 3, 3}; - int32_t toIBM930Offssub [] ={ 0, 0, 0, 1, 1, 2, 2, 3, 3}; - + int32_t toIBM930Offssub [] ={ 0, 0, 0, 1, 1, 2, 2, 3, 3}; + int32_t fromIBM949Offs [] = { 0, 1, 3, 5, 7}; - int32_t fromIBM943Offs [] = { 0, 2, 4, 6}; - int32_t fromIBM930Offs [] = { 1, 3, 5, 7}; - - gInBufferSize = inputsize; - gOutBufferSize = outputsize; + int32_t fromIBM943Offs [] = { 0, 2, 4, 6}; + int32_t fromIBM930Offs [] = { 1, 3, 5, 7}; + + gInBufferSize = inputsize; + gOutBufferSize = outputsize; /*from unicode*/ if(!testConvertFromUnicode(sampleText, sizeof(sampleText)/sizeof(sampleText[0]), - expsubIBM_949, sizeof(expsubIBM_949), "ibm-949", - (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SUBSTITUTE, toIBM949Offssub, NULL, 0 )) - log_err("u-> ibm-949 with subst did not match.\n"); + expsubIBM_949, sizeof(expsubIBM_949), "ibm-949", + (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SUBSTITUTE, toIBM949Offssub, NULL, 0 )) + log_err("u-> ibm-949 with subst did not match.\n"); if(!testConvertFromUnicode(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]), - expsubIBM_943, sizeof(expsubIBM_943), "ibm-943", - (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SUBSTITUTE, toIBM943Offssub , NULL, 0)) - log_err("u-> ibm-943 with subst did not match.\n"); + expsubIBM_943, sizeof(expsubIBM_943), "ibm-943", + (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SUBSTITUTE, toIBM943Offssub , NULL, 0)) + log_err("u-> ibm-943 with subst did not match.\n"); if(!testConvertFromUnicode(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]), - expsubIBM_930, sizeof(expsubIBM_930), "ibm-930", - (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SUBSTITUTE, toIBM930Offssub, NULL, 0 )) - log_err("u-> ibm-930 with subst did not match.\n"); + expsubIBM_930, sizeof(expsubIBM_930), "ibm-930", + (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SUBSTITUTE, toIBM930Offssub, NULL, 0 )) + log_err("u-> ibm-930 with subst did not match.\n"); - log_verbose("Testing fromUnicode with UCNV_FROM_U_CALLBACK_SUBSTITUTE \n"); + log_verbose("Testing fromUnicode with UCNV_FROM_U_CALLBACK_SUBSTITUTE \n"); { UChar inputTest[] = { 0x0061, 0xd801, 0xdc01, 0xd801, 0x0061 }; - const char toIBM943[]= { (char)0x61, (char)0xfc, (char)0xfc, (char)0xfc, (char)0xfc, (char)0x61 }; + const uint8_t toIBM943[]= { 0x61, 0xfc, 0xfc, 0xfc, 0xfc, 0x61 }; int32_t offset[]= {0, 1, 1, 3, 3, 4}; /* EUC_JP*/ UChar euc_jp_inputText[]={ 0x0061, 0x4edd, 0x5bec, 0xd801, 0xdc01, 0xd801, 0x0061, 0x00a2 }; - const char to_euc_jp[]={ (char)0x61, (char)0xa1, (char)0xb8, (char)0x8f, (char)0xf4, (char)0xae, - (char)0xf4, (char)0xfe, (char)0xf4, (char)0xfe, - (char)0x61, (char)0x8e, (char)0xe0, + const uint8_t to_euc_jp[]={ 0x61, 0xa1, 0xb8, 0x8f, 0xf4, 0xae, + 0xf4, 0xfe, 0xf4, 0xfe, + 0x61, 0x8e, 0xe0, }; int32_t fromEUC_JPOffs [] ={ 0, 1, 1, 2, 2, 2, 3, 3, 5, 5, 6, 7, 7}; /*EUC_TW*/ UChar euc_tw_inputText[]={ 0x0061, 0x2295, 0x5BF2, 0xd801, 0xdc01, 0xd801, 0x0061, 0x8706, 0x8a, }; - const char to_euc_tw[]={ - (char)0x61, (char)0xa2, (char)0xd3, (char)0x8e, (char)0xa2, (char)0xdc, (char)0xe5, - (char)0xfd, (char)0xfe, (char)0xfd, (char)0xfe, - (char)0x61, (char)0xe6, (char)0xca, (char)0x8a, + const uint8_t to_euc_tw[]={ + 0x61, 0xa2, 0xd3, 0x8e, 0xa2, 0xdc, 0xe5, + 0xfd, 0xfe, 0xfd, 0xfe, + 0x61, 0xe6, 0xca, 0x8a, }; int32_t from_euc_twOffs [] ={ 0, 1, 1, 2, 2, 2, 2, 3, 3, 5, 5, 6, 7, 7, 8,}; if(!testConvertFromUnicode(inputTest, sizeof(inputTest)/sizeof(inputTest[0]), - toIBM943, sizeof(toIBM943), "ibm-943", - (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SUBSTITUTE, offset, NULL, 0 )) - log_err("u-> ibm-943 with substitute did not match.\n"); - + toIBM943, sizeof(toIBM943), "ibm-943", + (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SUBSTITUTE, offset, NULL, 0 )) + log_err("u-> ibm-943 with substitute did not match.\n"); + if(!testConvertFromUnicode(euc_jp_inputText, sizeof(euc_jp_inputText)/sizeof(euc_jp_inputText[0]), - to_euc_jp, sizeof(to_euc_jp), "euc-jp", - (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SUBSTITUTE, fromEUC_JPOffs, NULL, 0 )) - log_err("u-> euc-jp with substitute did not match.\n"); + to_euc_jp, sizeof(to_euc_jp), "euc-jp", + (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SUBSTITUTE, fromEUC_JPOffs, NULL, 0 )) + log_err("u-> euc-jp with substitute did not match.\n"); if(!testConvertFromUnicode(euc_tw_inputText, sizeof(euc_tw_inputText)/sizeof(euc_tw_inputText[0]), - to_euc_tw, sizeof(to_euc_tw), "euc-tw", - (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SUBSTITUTE, from_euc_twOffs, NULL, 0 )) - log_err("u-> euc-tw with substitute did not match.\n"); - + to_euc_tw, sizeof(to_euc_tw), "euc-tw", + (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SUBSTITUTE, from_euc_twOffs, NULL, 0 )) + log_err("u-> euc-tw with substitute did not match.\n"); + } /*to unicode*/ - if(!testConvertToUnicode(expsubIBM_949, sizeof(expsubIBM_949), - IBM_949subtoUnicode, sizeof(IBM_949subtoUnicode)/sizeof(IBM_949subtoUnicode[0]),"ibm-949", - (UConverterToUCallback)UCNV_TO_U_CALLBACK_SUBSTITUTE, fromIBM949Offs, NULL, 0 )) - log_err("ibm-949->u with substitute did not match.\n"); - if(!testConvertToUnicode(expsubIBM_943, sizeof(expsubIBM_943), - IBM_943subtoUnicode, sizeof(IBM_943subtoUnicode)/sizeof(IBM_943subtoUnicode[0]),"ibm-943", - (UConverterToUCallback)UCNV_TO_U_CALLBACK_SUBSTITUTE, fromIBM943Offs, NULL, 0 )) - log_err("ibm-943->u with substitute did not match.\n"); - if(!testConvertToUnicode(expsubIBM_930, sizeof(expsubIBM_930), - IBM_930subtoUnicode, sizeof(IBM_930subtoUnicode)/sizeof(IBM_930subtoUnicode[0]),"ibm-930", - (UConverterToUCallback)UCNV_TO_U_CALLBACK_SUBSTITUTE, fromIBM930Offs, NULL, 0 )) - log_err("ibm-930->u with substitute did not match.\n"); + if(!testConvertToUnicode(expsubIBM_949, sizeof(expsubIBM_949), + IBM_949subtoUnicode, sizeof(IBM_949subtoUnicode)/sizeof(IBM_949subtoUnicode[0]),"ibm-949", + (UConverterToUCallback)UCNV_TO_U_CALLBACK_SUBSTITUTE, fromIBM949Offs, NULL, 0 )) + log_err("ibm-949->u with substitute did not match.\n"); + if(!testConvertToUnicode(expsubIBM_943, sizeof(expsubIBM_943), + IBM_943subtoUnicode, sizeof(IBM_943subtoUnicode)/sizeof(IBM_943subtoUnicode[0]),"ibm-943", + (UConverterToUCallback)UCNV_TO_U_CALLBACK_SUBSTITUTE, fromIBM943Offs, NULL, 0 )) + log_err("ibm-943->u with substitute did not match.\n"); + if(!testConvertToUnicode(expsubIBM_930, sizeof(expsubIBM_930), + IBM_930subtoUnicode, sizeof(IBM_930subtoUnicode)/sizeof(IBM_930subtoUnicode[0]),"ibm-930", + (UConverterToUCallback)UCNV_TO_U_CALLBACK_SUBSTITUTE, fromIBM930Offs, NULL, 0 )) + log_err("ibm-930->u with substitute did not match.\n"); log_verbose("Testing toUnicode with UCNV_TO_U_CALLBACK_SUBSTITUTE \n"); { - const char sampleTxtEBCIDIC_STATEFUL [] ={ - (char)0x0e, (char)0x5d, (char)0x5f , (char)0x41, (char)0x79, (char)0x41, (char)0x44 + const uint8_t sampleTxtEBCIDIC_STATEFUL [] ={ + 0x0e, 0x5d, 0x5f , 0x41, 0x79, 0x41, 0x44 }; UChar EBCIDIC_STATEFUL_toUnicode[] ={ 0x6d63, 0xfffd, 0x03b4 }; @@ -573,115 +577,115 @@ void TestSub(int32_t inputsize, int32_t outputsize) /* EUC_JP*/ - const char sampleTxt_euc_jp[]={ (char)0x61, (char)0xa1, (char)0xb8, (char)0x8f, (char)0xf4, (char)0xae, - (char)0x8f, (char)0xda, (char)0xa1, /*unassigned*/ - (char)0x8e, (char)0xe0, (char)0x8a + const uint8_t sampleTxt_euc_jp[]={ 0x61, 0xa1, 0xb8, 0x8f, 0xf4, 0xae, + 0x8f, 0xda, 0xa1, /*unassigned*/ + 0x8e, 0xe0, 0x8a }; UChar euc_jptoUnicode[]={ 0x0061, 0x4edd, 0x5bec, 0xfffd, 0x00a2, 0x008a }; int32_t from_euc_jpOffs [] ={ 0, 1, 3, 6, 9, 11 }; /*EUC_TW*/ - const char sampleTxt_euc_tw[]={ - (char)0x61, (char)0xa2, (char)0xd3, (char)0x8e, (char)0xa2, (char)0xdc, (char)0xe5, - (char)0x8e, (char)0xaa, (char)0xbb, (char)0xcc,/*unassigned*/ - (char)0xe6, (char)0xca, (char)0x8a, + const uint8_t sampleTxt_euc_tw[]={ + 0x61, 0xa2, 0xd3, 0x8e, 0xa2, 0xdc, 0xe5, + 0x8e, 0xaa, 0xbb, 0xcc,/*unassigned*/ + 0xe6, 0xca, 0x8a, }; UChar euc_twtoUnicode[]={ 0x0061, 0x2295, 0x5BF2, 0xfffd, 0x8706, 0x8a, }; int32_t from_euc_twOffs [] ={ 0, 1, 3, 7, 11, 13}; if(!testConvertToUnicode(sampleTxtEBCIDIC_STATEFUL, sizeof(sampleTxtEBCIDIC_STATEFUL), - EBCIDIC_STATEFUL_toUnicode, sizeof(EBCIDIC_STATEFUL_toUnicode)/sizeof(EBCIDIC_STATEFUL_toUnicode[0]),"ibm-930", - (UConverterToUCallback)UCNV_TO_U_CALLBACK_SUBSTITUTE, from_EBCIDIC_STATEFULOffsets, NULL, 0 )) - log_err("EBCIDIC_STATEFUL->u with substitute did not match.\n"); + EBCIDIC_STATEFUL_toUnicode, sizeof(EBCIDIC_STATEFUL_toUnicode)/sizeof(EBCIDIC_STATEFUL_toUnicode[0]),"ibm-930", + (UConverterToUCallback)UCNV_TO_U_CALLBACK_SUBSTITUTE, from_EBCIDIC_STATEFULOffsets, NULL, 0 )) + log_err("EBCIDIC_STATEFUL->u with substitute did not match.\n"); if(!testConvertToUnicode(sampleTxt_euc_jp, sizeof(sampleTxt_euc_jp), - euc_jptoUnicode, sizeof(euc_jptoUnicode)/sizeof(euc_jptoUnicode[0]),"euc-jp", - (UConverterToUCallback)UCNV_TO_U_CALLBACK_SUBSTITUTE, from_euc_jpOffs, NULL, 0 )) - log_err("euc-jp->u with substitute did not match.\n"); + euc_jptoUnicode, sizeof(euc_jptoUnicode)/sizeof(euc_jptoUnicode[0]),"euc-jp", + (UConverterToUCallback)UCNV_TO_U_CALLBACK_SUBSTITUTE, from_euc_jpOffs, NULL, 0 )) + log_err("euc-jp->u with substitute did not match.\n"); if(!testConvertToUnicode(sampleTxt_euc_tw, sizeof(sampleTxt_euc_tw), - euc_twtoUnicode, sizeof(euc_twtoUnicode)/sizeof(euc_twtoUnicode[0]),"euc-tw", - (UConverterToUCallback)UCNV_TO_U_CALLBACK_SUBSTITUTE, from_euc_twOffs, NULL, 0 )) - log_err("euc-tw->u with substitute did not match.\n"); - + euc_twtoUnicode, sizeof(euc_twtoUnicode)/sizeof(euc_twtoUnicode[0]),"euc-tw", + (UConverterToUCallback)UCNV_TO_U_CALLBACK_SUBSTITUTE, from_euc_twOffs, NULL, 0 )) + log_err("euc-tw->u with substitute did not match.\n"); + } - log_verbose("Testing fromUnicode for UTF-8 with UCNV_TO_U_CALLBACK_SUBSTITUTE \n"); + log_verbose("Testing fromUnicode for UTF-8 with UCNV_TO_U_CALLBACK_SUBSTITUTE \n"); { - const char sampleText1[] = { (char)0x31, (char)0xe4, (char)0xba, (char)0x8c, - (char)0xe0, (char)0x80, (char)0x61,}; + const uint8_t sampleText1[] = { 0x31, 0xe4, 0xba, 0x8c, + 0xe0, 0x80, 0x61,}; UChar expected1[] = { 0x0031, 0x4e8c, 0xfffd, 0x0061}; int32_t offsets1[] = { 0x0000, 0x0001, 0x0004, 0x0006}; if(!testConvertToUnicode(sampleText1, sizeof(sampleText1), - expected1, sizeof(expected1)/sizeof(expected1[0]),"utf8", - (UConverterToUCallback)UCNV_TO_U_CALLBACK_SUBSTITUTE, offsets1, NULL, 0 )) - log_err("utf8->u with substitute did not match.\n");; + expected1, sizeof(expected1)/sizeof(expected1[0]),"utf8", + (UConverterToUCallback)UCNV_TO_U_CALLBACK_SUBSTITUTE, offsets1, NULL, 0 )) + log_err("utf8->u with substitute did not match.\n");; } } void TestSubWithValue(int32_t inputsize, int32_t outputsize) { - UChar sampleText[] = { 0x0000, 0xAC00, 0xAC01, 0xEF67, 0xD700 }; - UChar sampleText2[] = { 0x6D63, 0x6D64, 0x6D65, 0x6D66 }; - - const char expsubwvalIBM_949[]= { - (char)0x00, (char)0xb0, (char)0xa1, (char)0xb0, (char)0xa2, - (char)0x25, (char)0x55, (char)0x45, (char)0x46, (char)0x36, (char)0x37, (char)0xc8, (char)0xd3 }; - - const char expsubwvalIBM_943[]= { - (char)0x9f, (char)0xaf, (char)0x9f, (char)0xb1, - (char)0x25, (char)0x55, (char)0x36, (char)0x44, (char)0x36, (char)0x35, (char)0x89, (char)0x59 }; - - const char expsubwvalIBM_930[] = { - (char)0x0e, (char)0x5d, (char)0x5f, (char)0x5d, (char)0x63, (char)0x0f, (char)0x6c, (char)0xe4, (char)0xf6, (char)0xc4, (char)0xf6, (char)0xf5, (char)0x0e, (char)0x46, (char)0x6b }; + UChar sampleText[] = { 0x0000, 0xAC00, 0xAC01, 0xEF67, 0xD700 }; + UChar sampleText2[] = { 0x6D63, 0x6D64, 0x6D65, 0x6D66 }; - int32_t toIBM949Offs [] ={ 0, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4}; - int32_t toIBM943Offs [] = { 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3}; - int32_t toIBM930Offs [] = { 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3}; /* last item: 3,3,3 because there's a shift plus a doublebyter .. */ + const uint8_t expsubwvalIBM_949[]= { + 0x00, 0xb0, 0xa1, 0xb0, 0xa2, + 0x25, 0x55, 0x45, 0x46, 0x36, 0x37, 0xc8, 0xd3 }; - gInBufferSize = inputsize; - gOutBufferSize = outputsize; + const uint8_t expsubwvalIBM_943[]= { + 0x9f, 0xaf, 0x9f, 0xb1, + 0x25, 0x55, 0x36, 0x44, 0x36, 0x35, 0x89, 0x59 }; + + const uint8_t expsubwvalIBM_930[] = { + 0x0e, 0x5d, 0x5f, 0x5d, 0x63, 0x0f, 0x6c, 0xe4, 0xf6, 0xc4, 0xf6, 0xf5, 0x0e, 0x46, 0x6b }; + + int32_t toIBM949Offs [] ={ 0, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4}; + int32_t toIBM943Offs [] = { 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3}; + int32_t toIBM930Offs [] = { 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3}; /* last item: 3,3,3 because there's a shift plus a doublebyter .. */ + + gInBufferSize = inputsize; + gOutBufferSize = outputsize; /*from Unicode*/ - if(!testConvertFromUnicode(sampleText, sizeof(sampleText)/sizeof(sampleText[0]), - expsubwvalIBM_949, sizeof(expsubwvalIBM_949), "ibm-949", - (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_ESCAPE, toIBM949Offs, NULL, 0 )) - log_err("u-> ibm-949 with subst with value did not match.\n"); + if(!testConvertFromUnicode(sampleText, sizeof(sampleText)/sizeof(sampleText[0]), + expsubwvalIBM_949, sizeof(expsubwvalIBM_949), "ibm-949", + (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_ESCAPE, toIBM949Offs, NULL, 0 )) + log_err("u-> ibm-949 with subst with value did not match.\n"); - if(!testConvertFromUnicode(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]), - expsubwvalIBM_943, sizeof(expsubwvalIBM_943), "ibm-943", - (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_ESCAPE, toIBM943Offs, NULL, 0 )) - log_err("u-> ibm-943 with sub with value did not match.\n"); + if(!testConvertFromUnicode(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]), + expsubwvalIBM_943, sizeof(expsubwvalIBM_943), "ibm-943", + (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_ESCAPE, toIBM943Offs, NULL, 0 )) + log_err("u-> ibm-943 with sub with value did not match.\n"); + + if(!testConvertFromUnicode(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]), + expsubwvalIBM_930, sizeof(expsubwvalIBM_930), "ibm-930", + (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_ESCAPE, toIBM930Offs, NULL, 0 )) + log_err("u-> ibm-930 with subst with value did not match.\n"); - if(!testConvertFromUnicode(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]), - expsubwvalIBM_930, sizeof(expsubwvalIBM_930), "ibm-930", - (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_ESCAPE, toIBM930Offs, NULL, 0 )) - log_err("u-> ibm-930 with subst with value did not match.\n"); - log_verbose("Testing fromUnicode with UCNV_FROM_U_CALLBACK_ESCAPE \n"); { UChar inputTest[] = { 0x0061, 0xd801, 0xdc01, 0xd801, 0x0061 }; - const char toIBM943[]= { (char)0x61, - (char)0x25, (char)0x55, (char)0x44, (char)0x38, (char)0x30, (char)0x31, - (char)0x25, (char)0x55, (char)0x44, (char)0x43, (char)0x30, (char)0x31, - (char)0x25, (char)0x55, (char)0x44, (char)0x38, (char)0x30, (char)0x31, - (char)0x61 }; + const uint8_t toIBM943[]= { 0x61, + 0x25, 0x55, 0x44, 0x38, 0x30, 0x31, + 0x25, 0x55, 0x44, 0x43, 0x30, 0x31, + 0x25, 0x55, 0x44, 0x38, 0x30, 0x31, + 0x61 }; int32_t offset[]= {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 4}; /* EUC_JP*/ UChar euc_jp_inputText[]={ 0x0061, 0x4edd, 0x5bec, 0xd801, 0xdc01, 0xd801, 0x0061, 0x00a2, }; - const char to_euc_jp[]={ (char)0x61, (char)0xa1, (char)0xb8, (char)0x8f, (char)0xf4, (char)0xae, - (char)0x25, (char)0x55, (char)0x44, (char)0x38, (char)0x30, (char)0x31, - (char)0x25, (char)0x55, (char)0x44, (char)0x43, (char)0x30, (char)0x31, - (char)0x25, (char)0x55, (char)0x44, (char)0x38, (char)0x30, (char)0x31, - (char)0x61, (char)0x8e, (char)0xe0, + const uint8_t to_euc_jp[]={ 0x61, 0xa1, 0xb8, 0x8f, 0xf4, 0xae, + 0x25, 0x55, 0x44, 0x38, 0x30, 0x31, + 0x25, 0x55, 0x44, 0x43, 0x30, 0x31, + 0x25, 0x55, 0x44, 0x38, 0x30, 0x31, + 0x61, 0x8e, 0xe0, }; int32_t fromEUC_JPOffs [] ={ 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, @@ -692,12 +696,12 @@ void TestSubWithValue(int32_t inputsize, int32_t outputsize) /*EUC_TW*/ UChar euc_tw_inputText[]={ 0x0061, 0x2295, 0x5BF2, 0xd801, 0xdc01, 0xd801, 0x0061, 0x8706, 0x8a, }; - const char to_euc_tw[]={ - (char)0x61, (char)0xa2, (char)0xd3, (char)0x8e, (char)0xa2, (char)0xdc, (char)0xe5, - (char)0x25, (char)0x55, (char)0x44, (char)0x38, (char)0x30, (char)0x31, - (char)0x25, (char)0x55, (char)0x44, (char)0x43, (char)0x30, (char)0x31, - (char)0x25, (char)0x55, (char)0x44, (char)0x38, (char)0x30, (char)0x31, - (char)0x61, (char)0xe6, (char)0xca, (char)0x8a, + const uint8_t to_euc_tw[]={ + 0x61, 0xa2, 0xd3, 0x8e, 0xa2, 0xdc, 0xe5, + 0x25, 0x55, 0x44, 0x38, 0x30, 0x31, + 0x25, 0x55, 0x44, 0x43, 0x30, 0x31, + 0x25, 0x55, 0x44, 0x38, 0x30, 0x31, + 0x61, 0xe6, 0xca, 0x8a, }; int32_t from_euc_twOffs [] ={ 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 5, 5, 5, 5, 5, @@ -705,40 +709,40 @@ void TestSubWithValue(int32_t inputsize, int32_t outputsize) }; if(!testConvertFromUnicode(inputTest, sizeof(inputTest)/sizeof(inputTest[0]), - toIBM943, sizeof(toIBM943), "ibm-943", - (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_ESCAPE, offset, NULL, 0 )) - log_err("u-> ibm-943 with subst with value did not match.\n"); + toIBM943, sizeof(toIBM943), "ibm-943", + (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_ESCAPE, offset, NULL, 0 )) + log_err("u-> ibm-943 with subst with value did not match.\n"); if(!testConvertFromUnicode(euc_jp_inputText, sizeof(euc_jp_inputText)/sizeof(euc_jp_inputText[0]), - to_euc_jp, sizeof(to_euc_jp), "euc-jp", - (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_ESCAPE, fromEUC_JPOffs, NULL, 0 )) - log_err("u-> euc-jp with subst with value did not match.\n"); + to_euc_jp, sizeof(to_euc_jp), "euc-jp", + (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_ESCAPE, fromEUC_JPOffs, NULL, 0 )) + log_err("u-> euc-jp with subst with value did not match.\n"); if(!testConvertFromUnicode(euc_tw_inputText, sizeof(euc_tw_inputText)/sizeof(euc_tw_inputText[0]), - to_euc_tw, sizeof(to_euc_tw), "euc-tw", - (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_ESCAPE, from_euc_twOffs, NULL, 0 )) - log_err("u-> euc-tw with subst with value did not match.\n"); - + to_euc_tw, sizeof(to_euc_tw), "euc-tw", + (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_ESCAPE, from_euc_twOffs, NULL, 0 )) + log_err("u-> euc-tw with subst with value did not match.\n"); + } - - + + log_verbose("Testing toUnicode with UCNV_FROM_U_CALLBACK_ESCAPE \n"); /*to Unicode*/ { - const char sampleTxtToU[]= { (char)0x00, (char)0x9f, (char)0xaf, - (char)0x81, (char)0xad, /*unassigned*/ - (char)0x89, (char)0xd3 }; - UChar IBM_943toUnicode[] = { 0x0000, 0x6D63, + const uint8_t sampleTxtToU[]= { 0x00, 0x9f, 0xaf, + 0x81, 0xad, /*unassigned*/ + 0x89, 0xd3 }; + UChar IBM_943toUnicode[] = { 0x0000, 0x6D63, 0x25, 0x58, 0x38, 0x31, 0x25, 0x58, 0x41, 0x44, 0x7B87}; - int32_t fromIBM943Offs [] = { 0, 1, 3, 3, 3, 3, 3, 3, 3, 3, 5}; + int32_t fromIBM943Offs [] = { 0, 1, 3, 3, 3, 3, 3, 3, 3, 3, 5}; /* EUC_JP*/ - const char sampleTxt_EUC_JP[]={ (char)0x61, (char)0xa1, (char)0xb8, (char)0x8f, (char)0xf4, (char)0xae, - (char)0x8f, (char)0xda, (char)0xa1, /*unassigned*/ - (char)0x8e, (char)0xe0, + const uint8_t sampleTxt_EUC_JP[]={ 0x61, 0xa1, 0xb8, 0x8f, 0xf4, 0xae, + 0x8f, 0xda, 0xa1, /*unassigned*/ + 0x8e, 0xe0, }; UChar EUC_JPtoUnicode[]={ 0x0061, 0x4edd, 0x5bec, 0x25, 0x58, 0x38, 0x46, 0x25, 0x58, 0x44, 0x41, 0x25, 0x58, 0x41, 0x31, @@ -749,10 +753,10 @@ void TestSubWithValue(int32_t inputsize, int32_t outputsize) }; /*EUC_TW*/ - const char sampleTxt_euc_tw[]={ - (char)0x61, (char)0xa2, (char)0xd3, (char)0x8e, (char)0xa2, (char)0xdc, (char)0xe5, - (char)0x8e, (char)0xaa, (char)0xbb, (char)0xcc,/*unassigned*/ - (char)0xe6, (char)0xca, (char)0x8a, + const uint8_t sampleTxt_euc_tw[]={ + 0x61, 0xa2, 0xd3, 0x8e, 0xa2, 0xdc, 0xe5, + 0x8e, 0xaa, 0xbb, 0xcc,/*unassigned*/ + 0xe6, 0xca, 0x8a, }; UChar euc_twtoUnicode[]={ 0x0061, 0x2295, 0x5BF2, 0x25, 0x58, 0x38, 0x45, 0x25, 0x58, 0x41, 0x41, 0x25, 0x58, 0x42, 0x42, 0x25, 0x58, 0x43, 0x43, @@ -762,9 +766,9 @@ void TestSubWithValue(int32_t inputsize, int32_t outputsize) 11, 13}; /*LMBCS*/ - const char sampleTxtLMBCS[]={ (char)0x12, (char)0xc9, (char)0x50, - (char)0x12, (char)0x92, (char)0xa0, /*unassigned*/ - (char)0x12, (char)0x92, (char)0xa1, + const uint8_t sampleTxtLMBCS[]={ 0x12, 0xc9, 0x50, + 0x12, 0x92, 0xa0, /*unassigned*/ + 0x12, 0x92, 0xa1, }; UChar LMBCSToUnicode[]={ 0x4e2e, 0x25, 0x58, 0x31, 0x32, 0x25, 0x58, 0x39, 0x32, 0x25, 0x58, 0x41, 0x30, @@ -775,543 +779,543 @@ void TestSubWithValue(int32_t inputsize, int32_t outputsize) if(!testConvertToUnicode(sampleTxtToU, sizeof(sampleTxtToU), - IBM_943toUnicode, sizeof(IBM_943toUnicode)/sizeof(IBM_943toUnicode[0]),"ibm-943", - (UConverterToUCallback)UCNV_TO_U_CALLBACK_ESCAPE, fromIBM943Offs, NULL, 0 )) - log_err("ibm-943->u with substitute with value did not match.\n"); + IBM_943toUnicode, sizeof(IBM_943toUnicode)/sizeof(IBM_943toUnicode[0]),"ibm-943", + (UConverterToUCallback)UCNV_TO_U_CALLBACK_ESCAPE, fromIBM943Offs, NULL, 0 )) + log_err("ibm-943->u with substitute with value did not match.\n"); if(!testConvertToUnicode(sampleTxt_EUC_JP, sizeof(sampleTxt_EUC_JP), - EUC_JPtoUnicode, sizeof(EUC_JPtoUnicode)/sizeof(EUC_JPtoUnicode[0]),"euc-jp", - (UConverterToUCallback)UCNV_TO_U_CALLBACK_ESCAPE, fromEUC_JPOffs, NULL, 0)) - log_err("euc-jp->u with substitute with value did not match.\n"); + EUC_JPtoUnicode, sizeof(EUC_JPtoUnicode)/sizeof(EUC_JPtoUnicode[0]),"euc-jp", + (UConverterToUCallback)UCNV_TO_U_CALLBACK_ESCAPE, fromEUC_JPOffs, NULL, 0)) + log_err("euc-jp->u with substitute with value did not match.\n"); if(!testConvertToUnicode(sampleTxt_euc_tw, sizeof(sampleTxt_euc_tw), - euc_twtoUnicode, sizeof(euc_twtoUnicode)/sizeof(euc_twtoUnicode[0]),"euc-tw", - (UConverterToUCallback)UCNV_TO_U_CALLBACK_ESCAPE, from_euc_twOffs, NULL, 0)) - log_err("euc-tw->u with substitute with value did not match.\n"); + euc_twtoUnicode, sizeof(euc_twtoUnicode)/sizeof(euc_twtoUnicode[0]),"euc-tw", + (UConverterToUCallback)UCNV_TO_U_CALLBACK_ESCAPE, from_euc_twOffs, NULL, 0)) + log_err("euc-tw->u with substitute with value did not match.\n"); /*got to confirm this*/ if(/* broken for icu 1.6, do not test */uprv_strcmp("1.6", U_ICU_VERSION) != 0 && !testConvertToUnicode(sampleTxtLMBCS, sizeof(sampleTxtLMBCS), - LMBCSToUnicode, sizeof(LMBCSToUnicode)/sizeof(LMBCSToUnicode[0]),"LMBCS", - (UConverterToUCallback)UCNV_TO_U_CALLBACK_ESCAPE, fromLMBCS, NULL, 0)) - log_err("LMBCS->u with substitute with value did not match.\n"); + LMBCSToUnicode, sizeof(LMBCSToUnicode)/sizeof(LMBCSToUnicode[0]),"LMBCS", + (UConverterToUCallback)UCNV_TO_U_CALLBACK_ESCAPE, fromLMBCS, NULL, 0)) + log_err("LMBCS->u with substitute with value did not match.\n"); } } void TestLegalAndOthers(int32_t inputsize, int32_t outputsize) { - UChar legalText[] = { 0x0000, 0xAC00, 0xAC01, 0xD700 }; - const char templegal949[] ={ (char)0x00, (char)0xb0, (char)0xa1, (char)0xb0, (char)0xa2, (char)0xc8, (char)0xd3 }; - int32_t to949legal[] = {0, 1, 1, 2, 2, 3, 3}; - + UChar legalText[] = { 0x0000, 0xAC00, 0xAC01, 0xD700 }; + const uint8_t templegal949[] ={ 0x00, 0xb0, 0xa1, 0xb0, 0xa2, 0xc8, 0xd3 }; + int32_t to949legal[] = {0, 1, 1, 2, 2, 3, 3}; - const char text943[] = { - (char)0x82, (char)0xa9, (char)0x82, (char)0x20, /*(char)0xc8,*/ (char)0x61, (char)0x8a, (char)0xbf, (char)0x8e, (char)0x9a }; + + const uint8_t text943[] = { + 0x82, 0xa9, 0x82, 0x20, /*0xc8,*/ 0x61, 0x8a, 0xbf, 0x8e, 0x9a }; UChar toUnicode943sub[] = { 0x304b, 0xfffd, /*0xff88,*/ 0x0061, 0x6f22, 0x5b57}; - UChar toUnicode943skip[]= { 0x304b, /*0xff88,*/ 0x0061, 0x6f22, 0x5b57}; - UChar toUnicode943stop[]= { 0x304b}; + UChar toUnicode943skip[]= { 0x304b, /*0xff88,*/ 0x0061, 0x6f22, 0x5b57}; + UChar toUnicode943stop[]= { 0x304b}; int32_t fromIBM943Offssub[] = {0, 2, 4, 5, 7}; - int32_t fromIBM943Offsskip[] = { 0, 4, 5, 7}; - int32_t fromIBM943Offsstop[] = { 0}; + int32_t fromIBM943Offsskip[] = { 0, 4, 5, 7}; + int32_t fromIBM943Offsstop[] = { 0}; - gInBufferSize = inputsize; - gOutBufferSize = outputsize; + gInBufferSize = inputsize; + gOutBufferSize = outputsize; /*checking with a legal value*/ - if(!testConvertFromUnicode(legalText, sizeof(legalText)/sizeof(legalText[0]), - templegal949, sizeof(templegal949), "ibm-949", - (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SKIP, to949legal, NULL, 0 )) - log_err("u-> ibm-949 with skip did not match.\n"); - + if(!testConvertFromUnicode(legalText, sizeof(legalText)/sizeof(legalText[0]), + templegal949, sizeof(templegal949), "ibm-949", + (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SKIP, to949legal, NULL, 0 )) + log_err("u-> ibm-949 with skip did not match.\n"); + /*checking illegal value for ibm-943 with substitute*/ if(!testConvertToUnicode(text943, sizeof(text943), - toUnicode943sub, sizeof(toUnicode943sub)/sizeof(toUnicode943sub[0]),"ibm-943", - (UConverterToUCallback)UCNV_TO_U_CALLBACK_SUBSTITUTE, fromIBM943Offssub, NULL, 0 )) - log_err("ibm-943->u with subst did not match.\n"); - /*checking illegal value for ibm-943 with skip */ - if(!testConvertToUnicode(text943, sizeof(text943), - toUnicode943skip, sizeof(toUnicode943skip)/sizeof(toUnicode943skip[0]),"ibm-943", - (UConverterToUCallback)UCNV_TO_U_CALLBACK_SKIP, fromIBM943Offsskip, NULL, 0 )) - log_err("ibm-943->u with skip did not match.\n"); + toUnicode943sub, sizeof(toUnicode943sub)/sizeof(toUnicode943sub[0]),"ibm-943", + (UConverterToUCallback)UCNV_TO_U_CALLBACK_SUBSTITUTE, fromIBM943Offssub, NULL, 0 )) + log_err("ibm-943->u with subst did not match.\n"); + /*checking illegal value for ibm-943 with skip */ + if(!testConvertToUnicode(text943, sizeof(text943), + toUnicode943skip, sizeof(toUnicode943skip)/sizeof(toUnicode943skip[0]),"ibm-943", + (UConverterToUCallback)UCNV_TO_U_CALLBACK_SKIP, fromIBM943Offsskip, NULL, 0 )) + log_err("ibm-943->u with skip did not match.\n"); - /*checking illegal value for ibm-943 with stop */ - if(!testConvertToUnicode(text943, sizeof(text943), - toUnicode943stop, sizeof(toUnicode943stop)/sizeof(toUnicode943stop[0]),"ibm-943", - (UConverterToUCallback)UCNV_TO_U_CALLBACK_STOP, fromIBM943Offsstop, NULL, 0 )) - log_err("ibm-943->u with stop did not match.\n"); + /*checking illegal value for ibm-943 with stop */ + if(!testConvertToUnicode(text943, sizeof(text943), + toUnicode943stop, sizeof(toUnicode943stop)/sizeof(toUnicode943stop[0]),"ibm-943", + (UConverterToUCallback)UCNV_TO_U_CALLBACK_STOP, fromIBM943Offsstop, NULL, 0 )) + log_err("ibm-943->u with stop did not match.\n"); } void TestSingleByte(int32_t inputsize, int32_t outputsize) { - const char sampleText[] = { - (char)0x82, (char)0xa9, (char)0x61, (char)0x62, (char)0x63 , (char)0x82, - (char)0xff, /*(char)0x82, (char)0xa9,*/ (char)0x32, (char)0x33}; - UChar toUnicode943sub[] = {0x304b, 0x0061, 0x0062, 0x0063, 0xfffd,/*0x304b,*/ 0x0032, 0x0033}; - int32_t fromIBM943Offssub[] = {0, 2, 3, 4, 5, 7, 8}; - /*checking illegal value for ibm-943 with substitute*/ - gInBufferSize = inputsize; - gOutBufferSize = outputsize; - + const uint8_t sampleText[] = { + 0x82, 0xa9, 0x61, 0x62, 0x63 , 0x82, + 0xff, /*0x82, 0xa9,*/ 0x32, 0x33}; + UChar toUnicode943sub[] = {0x304b, 0x0061, 0x0062, 0x0063, 0xfffd,/*0x304b,*/ 0x0032, 0x0033}; + int32_t fromIBM943Offssub[] = {0, 2, 3, 4, 5, 7, 8}; + /*checking illegal value for ibm-943 with substitute*/ + gInBufferSize = inputsize; + gOutBufferSize = outputsize; + if(!testConvertToUnicode(sampleText, sizeof(sampleText), - toUnicode943sub, sizeof(toUnicode943sub)/sizeof(toUnicode943sub[0]),"ibm-943", - (UConverterToUCallback)UCNV_TO_U_CALLBACK_SUBSTITUTE, fromIBM943Offssub, NULL, 0 )) - log_err("ibm-943->u with subst did not match.\n"); + toUnicode943sub, sizeof(toUnicode943sub)/sizeof(toUnicode943sub[0]),"ibm-943", + (UConverterToUCallback)UCNV_TO_U_CALLBACK_SUBSTITUTE, fromIBM943Offssub, NULL, 0 )) + log_err("ibm-943->u with subst did not match.\n"); } void TestEBCDIC_STATEFUL_Sub(int32_t inputsize, int32_t outputsize) { /*EBCDIC_STATEFUL*/ UChar ebcdic_inputTest[] = { 0x0061, 0x6d64, 0x0061, 0x00A2, 0x6d65 }; - const char toIBM930[]= { (char)0x62, (char)0x0e, (char)0x5d, (char)0x63, (char)0x0f, - (char)0x62, (char)0xb1, (char)0x0e, (char)0xfe, (char)0xfe, (char)0x0f}; + const uint8_t toIBM930[]= { 0x62, 0x0e, 0x5d, 0x63, 0x0f, + 0x62, 0xb1, 0x0e, 0xfe, 0xfe, 0x0f}; int32_t offset_930[]={0, 1, 1, 1, 2, 2, 3, 4, 4, 4, 4,}; - const char toIBM930_maxbuffer[]= { (char)0x62, (char)0x0e, (char)0x5d, (char)0x63, (char)0x0f, - (char)0x62, (char)0xb1, (char)0xfe, (char)0xfe}; + const uint8_t toIBM930_maxbuffer[]= { 0x62, 0x0e, 0x5d, 0x63, 0x0f, + 0x62, 0xb1, 0xfe, 0xfe}; int32_t offset_930_maxbuffer[]={0, 1, 1, 1, 2, 2, 3, 4, 4, }; /* s E doubl F sng s fe fe */ /*EBCDIC_STATEFUL with subChar=3f*/ - const char toIBM930_subvaried[]= { (char)0x62, (char)0x0e, (char)0x5d, (char)0x63, (char)0x0f, (char)0x62, (char)0xb1, (char)0x3f}; + const uint8_t toIBM930_subvaried[]= { 0x62, 0x0e, 0x5d, 0x63, 0x0f, 0x62, 0xb1, 0x3f}; int32_t offset_930_subvaried[]= {0, 1, 1, 1, 1, 2, 3, 4, }; - const char mySubChar[]={ (char)0x3f}; + const char mySubChar[]={ 0x3f}; - const char toIBM930_subvaried_maxbuffer[]= { (char)0x62, (char)0x0e, (char)0x5d, (char)0x63, (char)0x0f, (char)0x62, (char)0xb1, (char)0x0f, (char)0x3f, (char)0x0e}; + const uint8_t toIBM930_subvaried_maxbuffer[]= { 0x62, 0x0e, 0x5d, 0x63, 0x0f, 0x62, 0xb1, 0x0f, 0x3f, 0x0e}; int32_t offset_930_subvaried_maxbuffer[]= {0, 1, 1, 1, 2, 2, 3, 4, 4, 4, 4,}; gInBufferSize = inputsize; - gOutBufferSize = outputsize; + gOutBufferSize = outputsize; if(gInBufferSize == NEW_MAX_BUFFER && gOutBufferSize == NEW_MAX_BUFFER){ if(!testConvertFromUnicode(ebcdic_inputTest, sizeof(ebcdic_inputTest)/sizeof(ebcdic_inputTest[0]), - toIBM930_maxbuffer, sizeof(toIBM930_maxbuffer), "ibm-930", - (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SUBSTITUTE, offset_930, NULL, 0 )) - log_err("u-> ibm-930(EBCDIC_STATEFUL) with subst did not match.\n"); - + toIBM930_maxbuffer, sizeof(toIBM930_maxbuffer), "ibm-930", + (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SUBSTITUTE, offset_930, NULL, 0 )) + log_err("u-> ibm-930(EBCDIC_STATEFUL) with subst did not match.\n"); + if(!testConvertFromUnicode(ebcdic_inputTest, sizeof(ebcdic_inputTest)/sizeof(ebcdic_inputTest[0]), - toIBM930_subvaried_maxbuffer, sizeof(toIBM930_subvaried_maxbuffer), "ibm-930", - (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SUBSTITUTE, offset_930_subvaried_maxbuffer, mySubChar, 1 )) - log_err("u-> ibm-930(EBCDIC_STATEFUL) with subst(setSubChar=0x3f) did not match.\n"); + toIBM930_subvaried_maxbuffer, sizeof(toIBM930_subvaried_maxbuffer), "ibm-930", + (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SUBSTITUTE, offset_930_subvaried_maxbuffer, mySubChar, 1 )) + log_err("u-> ibm-930(EBCDIC_STATEFUL) with subst(setSubChar=0x3f) did not match.\n"); }else { + + if(!testConvertFromUnicode(ebcdic_inputTest, sizeof(ebcdic_inputTest)/sizeof(ebcdic_inputTest[0]), + toIBM930, sizeof(toIBM930), "ibm-930", + (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SUBSTITUTE, offset_930, NULL, 0 )) + log_err("u-> ibm-930(EBCDIC_STATEFUL) with subst did not match.\n"); if(!testConvertFromUnicode(ebcdic_inputTest, sizeof(ebcdic_inputTest)/sizeof(ebcdic_inputTest[0]), - toIBM930, sizeof(toIBM930), "ibm-930", - (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SUBSTITUTE, offset_930, NULL, 0 )) - log_err("u-> ibm-930(EBCDIC_STATEFUL) with subst did not match.\n"); - - if(!testConvertFromUnicode(ebcdic_inputTest, sizeof(ebcdic_inputTest)/sizeof(ebcdic_inputTest[0]), - toIBM930_subvaried, sizeof(toIBM930_subvaried), "ibm-930", - (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SUBSTITUTE, offset_930_subvaried, mySubChar, 1 )) - log_err("u-> ibm-930(EBCDIC_STATEFUL) with subst(setSubChar=0x3f) did not match.\n"); + toIBM930_subvaried, sizeof(toIBM930_subvaried), "ibm-930", + (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SUBSTITUTE, offset_930_subvaried, mySubChar, 1 )) + log_err("u-> ibm-930(EBCDIC_STATEFUL) with subst(setSubChar=0x3f) did not match.\n"); } - + } - -UBool testConvertFromUnicode(const UChar *source, int sourceLen, const char *expect, int expectLen, - const char *codepage, UConverterFromUCallback callback , int32_t *expectOffsets, + +UBool testConvertFromUnicode(const UChar *source, int sourceLen, const uint8_t *expect, int expectLen, + const char *codepage, UConverterFromUCallback callback , int32_t *expectOffsets, const char *mySubChar, int8_t len) { - - - UErrorCode status = U_ZERO_ERROR; - UConverter *conv = 0; - char junkout[NEW_MAX_BUFFER]; /* FIX */ - int32_t junokout[NEW_MAX_BUFFER]; /* FIX */ - const UChar *src; - char *end; - char *targ; - int32_t *offs; - int i; - int32_t realBufferSize; - char *realBufferEnd; - const UChar *realSourceEnd; - const UChar *sourceLimit; - UBool checkOffsets = TRUE; - UBool doFlush; - char junk[9999]; - char offset_str[9999]; - char *p; + + + UErrorCode status = U_ZERO_ERROR; + UConverter *conv = 0; + uint8_t junkout[NEW_MAX_BUFFER]; /* FIX */ + int32_t junokout[NEW_MAX_BUFFER]; /* FIX */ + const UChar *src; + uint8_t *end; + uint8_t *targ; + int32_t *offs; + int i; + int32_t realBufferSize; + uint8_t *realBufferEnd; + const UChar *realSourceEnd; + const UChar *sourceLimit; + UBool checkOffsets = TRUE; + UBool doFlush; + char junk[9999]; + char offset_str[9999]; + uint8_t *p; UConverterFromUCallback oldAction = NULL; void* oldContext = NULL; - - - for(i=0;i %d chars out]. \nResult :", + sourceLen, targ-junkout); + if(VERBOSITY) + { + + junk[0] = 0; + offset_str[0] = 0; for(p = junkout;p %d chars out]. \nResult :", - sourceLen, targ-junkout); - if(VERBOSITY) - { - - junk[0] = 0; - offset_str[0] = 0; - for(p = junkout;p %d chars.\nResult :", + sourcelen, targ-junkout); + if(VERBOSITY) + { - log_verbose("\nConversion done. %d bytes -> %d chars.\nResult :", - sourcelen, targ-junkout); - if(VERBOSITY) - { - - junk[0] = 0; - offset_str[0] = 0; + junk[0] = 0; + offset_str[0] = 0; - for(p = junkout;p