/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2006, International Business Machines Corporation and
+ * Copyright (c) 1997-2011, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/*
#include "unicode/ustring.h"
#include "nccbtst.h"
#include "unicode/ucnv_cb.h"
+#include "unicode/utf16.h"
+
#define NEW_MAX_BUFFER 999
#define nct_min(x,y) ((x<y) ? x : y)
log_verbose("Testing UTF-7 toUnicode with substitute callbacks\n");
{
static const uint8_t utf7[]={
- /* a~ a+AB~ a+AB\x0c a+AB- a+AB. a+. */
- 0x61, 0x7e, 0x61, 0x2b, 0x41, 0x42, 0x7e, 0x61, 0x2b, 0x41, 0x42, 0x0c, 0x61, 0x2b, 0x41, 0x42, 0x2d, 0x61, 0x2b, 0x41, 0x42, 0x2e, 0x61, 0x2b, 0x2e
+ /* a~ a+AB~ a+AB\x0c a+AB- a+AB. a+. */
+ 0x61, 0x7e, 0x61, 0x2b, 0x41, 0x42, 0x7e, 0x61, 0x2b, 0x41, 0x42, 0x0c, 0x61, 0x2b, 0x41, 0x42, 0x2d, 0x61, 0x2b, 0x41, 0x42, 0x2e, 0x61, 0x2b, 0x2e
};
static const UChar unicode[]={
- 0x61, 0xfffd, 0x61, 0xfffd, 0x61, 0xfffd, 0x61, 0xfffd, 0x61, 0xfffd, 0x61, 0xfffd
+ 0x61, 0xfffd, 0x61, 0xfffd, 0xfffd, 0x61, 0xfffd, 0xfffd, 0x61, 0xfffd, 0x61, 0xfffd, 0x2e, 0x61, 0xfffd, 0x2e
};
static const int32_t offsets[]={
- 0, 1, 2, 4, 7, 9, 12, 14, 17, 19, 22, 23
+ 0, 1, 2, 4, 6, 7, 9, 11, 12, 14, 17, 19, 21, 22, 23, 24
};
if(!testConvertToUnicode(utf7, ARRAY_LENGTH(utf7), unicode, ARRAY_LENGTH(unicode), "UTF-7",
in4[]={ 0x00, 0x01, 0x02, 0x03, 0x00, 0x11, 0x12, 0x00, 0x00, 0x00, 0x4e, 0x00 };
static const UChar
- out1[]={ UTF16_LEAD(0x100f00), UTF16_TRAIL(0x100f00), 0xfeff },
- out2[]={ UTF16_LEAD(0x0f1000), UTF16_TRAIL(0x0f1000), 0xfffe },
- out3[]={ 0xfefe, UTF16_LEAD(0x100f00), UTF16_TRAIL(0x100f00), 0xfffd, 0xfffd },
- out4[]={ UTF16_LEAD(0x10203), UTF16_TRAIL(0x10203), 0xfffd, 0x4e00 };
+ out1[]={ U16_LEAD(0x100f00), U16_TRAIL(0x100f00), 0xfeff },
+ out2[]={ U16_LEAD(0x0f1000), U16_TRAIL(0x0f1000), 0xfffe },
+ out3[]={ 0xfefe, U16_LEAD(0x100f00), U16_TRAIL(0x100f00), 0xfffd, 0xfffd },
+ out4[]={ U16_LEAD(0x10203), U16_TRAIL(0x10203), 0xfffd, 0x4e00 };
static const int32_t
offsets1[]={ 4, 4, 8 },
UCNV_FROM_U_CALLBACK_ESCAPE, from_iso_2022_cnOffs7_v2, NULL, 0,"K" ,U_ZERO_ERROR ))
log_err("u-> iso-2022-cn with sub & K did not match.\n");
+ }
+ {
+ static const UChar iso_2022_cn_inputText8[]={
+ 0x3000,
+ 0xD84D, 0xDC56,
+ 0x3001,
+ 0xD84D, 0xDC56,
+ 0xDBFF, 0xDFFF,
+ 0x0042,
+ 0x0902};
+ static const uint8_t to_iso_2022_cn8_v2[]={
+ 0x1b, 0x24, 0x29, 0x41, 0x0e, 0x21, 0x21,
+ 0x0f, 0x5c, 0x32, 0x33, 0x34, 0x35, 0x36, 0x20,
+ 0x0e, 0x21, 0x22,
+ 0x0f, 0x5c, 0x32, 0x33, 0x34, 0x35, 0x36, 0x20,
+ 0x5c, 0x31, 0x30, 0x46, 0x46, 0x46, 0x46, 0x20,
+ 0x42,
+ 0x5c, 0x39, 0x30, 0x32, 0x20
+ };
+ static const int32_t from_iso_2022_cnOffs8_v2 [] ={
+ 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 3, 3, 3,
+ 4, 4, 4, 4, 4, 4, 4, 4,
+ 6, 6, 6, 6, 6, 6, 6, 6,
+ 8,
+ 9, 9, 9, 9, 9
+ };
+ if(!testConvertFromUnicodeWithContext(iso_2022_cn_inputText8, sizeof(iso_2022_cn_inputText8)/sizeof(iso_2022_cn_inputText8[0]),
+ to_iso_2022_cn8_v2, sizeof(to_iso_2022_cn8_v2), "iso-2022-cn",
+ UCNV_FROM_U_CALLBACK_ESCAPE, from_iso_2022_cnOffs8_v2, NULL, 0,UCNV_ESCAPE_CSS2,U_ZERO_ERROR ))
+ log_err("u-> iso-2022-cn with sub & UCNV_ESCAPE_CSS2 did not match.\n");
+
}
{
static const uint8_t to_iso_2022_cn4_v3[]={
static const uint8_t text943[] = {
- 0x82, 0xa9, 0x82, 0x20, /*0xc8,*/ 0x61, 0x8a, 0xbf, 0x8e, 0x9a };
- static const UChar toUnicode943sub[] = { 0x304b, 0xfffd, /*0xff88,*/ 0x0061, 0x6f22, 0x5b57};
- static const UChar toUnicode943skip[]= { 0x304b, /*0xff88,*/ 0x0061, 0x6f22, 0x5b57};
+ 0x82, 0xa9, 0x82, 0x20, 0x61, 0x8a, 0xbf, 0x8e, 0x9a };
+ static const UChar toUnicode943sub[] = { 0x304b, 0x1a, 0x20, 0x0061, 0x6f22, 0x5b57 };
+ static const UChar toUnicode943skip[]= { 0x304b, 0x20, 0x0061, 0x6f22, 0x5b57 };
static const UChar toUnicode943stop[]= { 0x304b};
- static const int32_t fromIBM943Offssub[] = {0, 2, 4, 5, 7};
- static const int32_t fromIBM943Offsskip[] = { 0, 4, 5, 7};
+ static const int32_t fromIBM943Offssub[] = { 0, 2, 3, 4, 5, 7 };
+ static const int32_t fromIBM943Offsskip[] = { 0, 3, 4, 5, 7 };
static const int32_t fromIBM943Offsstop[] = { 0};
gInBufferSize = inputsize;
{
static const uint8_t sampleText[] = {
0x82, 0xa9, 0x61, 0x62, 0x63 , 0x82,
- 0xff, /*0x82, 0xa9,*/ 0x32, 0x33};
- static const UChar toUnicode943sub[] = {0x304b, 0x0061, 0x0062, 0x0063, 0xfffd,/*0x304b,*/ 0x0032, 0x0033};
- static const int32_t fromIBM943Offssub[] = {0, 2, 3, 4, 5, 7, 8};
+ 0xff, 0x32, 0x33};
+ static const UChar toUnicode943sub[] = { 0x304b, 0x0061, 0x0062, 0x0063, 0x1a, 0x1a, 0x0032, 0x0033 };
+ static const int32_t fromIBM943Offssub[] = { 0, 2, 3, 4, 5, 6, 7, 8 };
/*checking illegal value for ibm-943 with substitute*/
gInBufferSize = inputsize;
gOutBufferSize = outputsize;
log_verbose("\nConversion done [%d uchars in -> %d chars out]. \nResult :",
sourceLen, targ-junkout);
- if(VERBOSITY)
+ if(getTestOption(VERBOSITY_OPTION))
{
junk[0] = 0;
log_verbose("\nConversion done. %d bytes -> %d chars.\nResult :",
sourcelen, targ-junkout);
- if(VERBOSITY)
+ if(getTestOption(VERBOSITY_OPTION))
{
junk[0] = 0;
log_verbose("\nConversion done [%d uchars in -> %d chars out]. \nResult :",
sourceLen, targ-junkout);
- if(VERBOSITY)
+ if(getTestOption(VERBOSITY_OPTION))
{
junk[0] = 0;
log_verbose("\nConversion done. %d bytes -> %d chars.\nResult :",
sourcelen, targ-junkout);
- if(VERBOSITY)
+ if(getTestOption(VERBOSITY_OPTION))
{
junk[0] = 0;
log_err("Error: ucnv_cbToUWriteUChars did not react correctly to a bad UErrorCode\n");
}
}
-