]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/cintltst/ncnvtst.c
ICU-62135.0.1.tar.gz
[apple/icu.git] / icuSources / test / cintltst / ncnvtst.c
index 1b26b145aef222b892a1c0319832709a208435d7..255020a2e9c9f2e82454f660bdc6425c64082ab7 100644 (file)
@@ -1,16 +1,18 @@
+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
 /********************************************************************
  * COPYRIGHT: 
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1997-2006, International Business Machines Corporation and
+ * Copyright (c) 1997-2016, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
  * others. All Rights Reserved.
  ********************************************************************/
-/*******************************************************************************
+/*****************************************************************************
 *
 *
-* File CCONVTST.C
+* File ncnvtst.c
 *
 * Modification History:
 *        Name                     Description
 *   Madhu Katragadda              7/7/2000        Converter Tests for extended code coverage
 *
 * Modification History:
 *        Name                     Description
 *   Madhu Katragadda              7/7/2000        Converter Tests for extended code coverage
-********************************************************************************
+******************************************************************************
 */
 #include <stdio.h>
 #include <stdlib.h>
 */
 #include <stdio.h>
 #include <stdlib.h>
 #include "unicode/utypes.h"
 #include "unicode/ustring.h"
 #include "unicode/uset.h"
 #include "unicode/utypes.h"
 #include "unicode/ustring.h"
 #include "unicode/uset.h"
+#include "unicode/utf8.h"
+#include "unicode/utf16.h"
 #include "cintltst.h"
 #include "cintltst.h"
+#include "cmemory.h"
 
 #define MAX_LENGTH 999
 
 
 #define MAX_LENGTH 999
 
@@ -33,7 +38,6 @@ static int32_t  gOutBufferSize = 0;
 static char     gNuConvTestName[1024];
 
 #define nct_min(x,y)  ((x<y) ? x : y)
 static char     gNuConvTestName[1024];
 
 #define nct_min(x,y)  ((x<y) ? x : y)
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
 
 static void printSeq(const unsigned char* a, int len);
 static void printSeqErr(const unsigned char* a, int len);
 
 static void printSeq(const unsigned char* a, int len);
 static void printSeqErr(const unsigned char* a, int len);
@@ -143,13 +147,13 @@ static void TestSurrogateBehaviour(){
 
 #if !UCONFIG_NO_LEGACY_CONVERSION
         /*SBCS*/
 
 #if !UCONFIG_NO_LEGACY_CONVERSION
         /*SBCS*/
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected, sizeof(expected), "ibm-920", 0 , TRUE, U_ZERO_ERROR))
             log_err("u-> ibm-920 [UCNV_SBCS] not match.\n");
 #endif
 
         /*LATIN_1*/
                 expected, sizeof(expected), "ibm-920", 0 , TRUE, U_ZERO_ERROR))
             log_err("u-> ibm-920 [UCNV_SBCS] not match.\n");
 #endif
 
         /*LATIN_1*/
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected, sizeof(expected), "LATIN_1", 0, TRUE, U_ZERO_ERROR ))
             log_err("u-> LATIN_1 not match.\n");
 
                 expected, sizeof(expected), "LATIN_1", 0, TRUE, U_ZERO_ERROR ))
             log_err("u-> LATIN_1 not match.\n");
 
@@ -163,17 +167,17 @@ static void TestSurrogateBehaviour(){
         int32_t offsets[]        = {0x00, 0x00, 0x01, 0x01, 0x03, 0x03 };
 
         /*DBCS*/
         int32_t offsets[]        = {0x00, 0x00, 0x01, 0x01, 0x03, 0x03 };
 
         /*DBCS*/
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected, sizeof(expected), "ibm-1363", 0 , TRUE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_DBCS portion] not match.\n");
                 expected, sizeof(expected), "ibm-1363", 0 , TRUE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_DBCS portion] not match.\n");
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected, sizeof(expected), "ibm-1363", offsets , TRUE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_DBCS portion] not match.\n");
         /*MBCS*/
                 expected, sizeof(expected), "ibm-1363", offsets , TRUE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_DBCS portion] not match.\n");
         /*MBCS*/
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected, sizeof(expected), "ibm-1363", 0 , TRUE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_MBCS] not match.\n");
                 expected, sizeof(expected), "ibm-1363", 0 , TRUE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_MBCS] not match.\n");
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected, sizeof(expected), "ibm-1363", offsets, TRUE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_MBCS] not match.\n");
     }
                 expected, sizeof(expected), "ibm-1363", offsets, TRUE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_MBCS] not match.\n");
     }
@@ -189,10 +193,10 @@ static void TestSurrogateBehaviour(){
         int32_t offsets[] = {0,0,0,0,0,1,1,2,2,2,2,3,5 };
 
         /*iso-2022-jp*/
         int32_t offsets[] = {0,0,0,0,0,1,1,2,2,2,2,3,5 };
 
         /*iso-2022-jp*/
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected, sizeof(expected), "iso-2022-jp", 0 , TRUE, U_ZERO_ERROR))
             log_err("u-> not match.\n");
                 expected, sizeof(expected), "iso-2022-jp", 0 , TRUE, U_ZERO_ERROR))
             log_err("u-> not match.\n");
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected, sizeof(expected), "iso-2022-jp", offsets , TRUE, U_ZERO_ERROR))
             log_err("u->  not match.\n");
     }
                 expected, sizeof(expected), "iso-2022-jp", offsets , TRUE, U_ZERO_ERROR))
             log_err("u->  not match.\n");
     }
@@ -219,10 +223,10 @@ static void TestSurrogateBehaviour(){
                                     5,  };
 
         /*iso-2022-CN*/
                                     5,  };
 
         /*iso-2022-CN*/
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected, sizeof(expected), "iso-2022-cn", 0 , TRUE, U_ZERO_ERROR))
             log_err("u-> not match.\n");
                 expected, sizeof(expected), "iso-2022-cn", 0 , TRUE, U_ZERO_ERROR))
             log_err("u-> not match.\n");
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected, sizeof(expected), "iso-2022-cn", offsets , TRUE, U_ZERO_ERROR))
             log_err("u-> not match.\n");
     }
                 expected, sizeof(expected), "iso-2022-cn", offsets , TRUE, U_ZERO_ERROR))
             log_err("u-> not match.\n");
     }
@@ -249,10 +253,10 @@ static void TestSurrogateBehaviour(){
                             };
 
         /*iso-2022-kr*/
                             };
 
         /*iso-2022-kr*/
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected, sizeof(expected), "iso-2022-kr", 0 , TRUE, U_ZERO_ERROR))
             log_err("u-> iso-2022-kr [UCNV_DBCS] not match.\n");
                 expected, sizeof(expected), "iso-2022-kr", 0 , TRUE, U_ZERO_ERROR))
             log_err("u-> iso-2022-kr [UCNV_DBCS] not match.\n");
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected, sizeof(expected), "iso-2022-kr", offsets , TRUE, U_ZERO_ERROR))
             log_err("u-> iso-2022-kr [UCNV_DBCS] not match.\n");
     }
                 expected, sizeof(expected), "iso-2022-kr", offsets , TRUE, U_ZERO_ERROR))
             log_err("u-> iso-2022-kr [UCNV_DBCS] not match.\n");
     }
@@ -277,10 +281,10 @@ static void TestSurrogateBehaviour(){
                              7,};
 
         /*hz*/
                              7,};
 
         /*hz*/
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected, sizeof(expected), "HZ", 0 , TRUE, U_ZERO_ERROR))
             log_err("u-> HZ not match.\n");
                 expected, sizeof(expected), "HZ", 0 , TRUE, U_ZERO_ERROR))
             log_err("u-> HZ not match.\n");
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected, sizeof(expected), "HZ", offsets , TRUE, U_ZERO_ERROR))
             log_err("u-> HZ not match.\n");
     }
                 expected, sizeof(expected), "HZ", offsets , TRUE, U_ZERO_ERROR))
             log_err("u-> HZ not match.\n");
     }
@@ -299,30 +303,30 @@ static void TestSurrogateBehaviour(){
 
         static const int32_t fromOffsets[] = { 0x0000, 0x0003, 0x0005, 0x0006, 0x0009, 0x0009, 0x000D }; 
         /*UTF-8*/
 
         static const int32_t fromOffsets[] = { 0x0000, 0x0003, 0x0005, 0x0006, 0x0009, 0x0009, 0x000D }; 
         /*UTF-8*/
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
             expected, sizeof(expected), "UTF8", offsets, TRUE, U_ZERO_ERROR ))
             log_err("u-> UTF8 with offsets and flush true did not match.\n");
             expected, sizeof(expected), "UTF8", offsets, TRUE, U_ZERO_ERROR ))
             log_err("u-> UTF8 with offsets and flush true did not match.\n");
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
             expected, sizeof(expected), "UTF8", 0, TRUE, U_ZERO_ERROR ))
             log_err("u-> UTF8 with offsets and flush true did not match.\n");
             expected, sizeof(expected), "UTF8", 0, TRUE, U_ZERO_ERROR ))
             log_err("u-> UTF8 with offsets and flush true did not match.\n");
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
             expected, sizeof(expected), "UTF8", offsets, FALSE, U_ZERO_ERROR ))
             log_err("u-> UTF8 with offsets and flush true did not match.\n");
             expected, sizeof(expected), "UTF8", offsets, FALSE, U_ZERO_ERROR ))
             log_err("u-> UTF8 with offsets and flush true did not match.\n");
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
             expected, sizeof(expected), "UTF8", 0, FALSE, U_ZERO_ERROR ))
             log_err("u-> UTF8 with offsets and flush true did not match.\n");
 
         if(!convertToU(expected, sizeof(expected), 
             expected, sizeof(expected), "UTF8", 0, FALSE, U_ZERO_ERROR ))
             log_err("u-> UTF8 with offsets and flush true did not match.\n");
 
         if(!convertToU(expected, sizeof(expected), 
-            sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "UTF8", 0, TRUE, U_ZERO_ERROR ))
+            sampleText, UPRV_LENGTHOF(sampleText), "UTF8", 0, TRUE, U_ZERO_ERROR ))
             log_err("UTF8 -> u did not match.\n");
         if(!convertToU(expected, sizeof(expected), 
             log_err("UTF8 -> u did not match.\n");
         if(!convertToU(expected, sizeof(expected), 
-            sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "UTF8", 0, FALSE, U_ZERO_ERROR ))
+            sampleText, UPRV_LENGTHOF(sampleText), "UTF8", 0, FALSE, U_ZERO_ERROR ))
             log_err("UTF8 -> u did not match.\n");
         if(!convertToU(expected, sizeof(expected), 
             log_err("UTF8 -> u did not match.\n");
         if(!convertToU(expected, sizeof(expected), 
-            sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "UTF8", fromOffsets, TRUE, U_ZERO_ERROR ))
+            sampleText, UPRV_LENGTHOF(sampleText), "UTF8", fromOffsets, TRUE, U_ZERO_ERROR ))
             log_err("UTF8 ->u  did not match.\n");
         if(!convertToU(expected, sizeof(expected), 
             log_err("UTF8 ->u  did not match.\n");
         if(!convertToU(expected, sizeof(expected), 
-            sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "UTF8", fromOffsets, FALSE, U_ZERO_ERROR ))
+            sampleText, UPRV_LENGTHOF(sampleText), "UTF8", fromOffsets, FALSE, U_ZERO_ERROR ))
             log_err("UTF8 -> u did not match.\n");
 
     }
             log_err("UTF8 -> u did not match.\n");
 
     }
@@ -340,26 +344,26 @@ static void TestErrorBehaviour(){
 
 #if !UCONFIG_NO_LEGACY_CONVERSION
         /*SBCS*/
 
 #if !UCONFIG_NO_LEGACY_CONVERSION
         /*SBCS*/
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected, sizeof(expected), "ibm-920", 0, TRUE, U_ZERO_ERROR))
             log_err("u-> ibm-920 [UCNV_SBCS] \n");
                 expected, sizeof(expected), "ibm-920", 0, TRUE, U_ZERO_ERROR))
             log_err("u-> ibm-920 [UCNV_SBCS] \n");
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected0, sizeof(expected0), "ibm-920", 0, FALSE, U_ZERO_ERROR))
             log_err("u-> ibm-920 [UCNV_SBCS] \n");
                 expected0, sizeof(expected0), "ibm-920", 0, FALSE, U_ZERO_ERROR))
             log_err("u-> ibm-920 [UCNV_SBCS] \n");
-        if(!convertFromU(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]),
+        if(!convertFromU(sampleText2, UPRV_LENGTHOF(sampleText2),
                 expected2, sizeof(expected2), "ibm-920", 0, TRUE, U_ZERO_ERROR))
             log_err("u-> ibm-920 [UCNV_SBCS] did not match\n");
 #endif
 
         /*LATIN_1*/
                 expected2, sizeof(expected2), "ibm-920", 0, TRUE, U_ZERO_ERROR))
             log_err("u-> ibm-920 [UCNV_SBCS] did not match\n");
 #endif
 
         /*LATIN_1*/
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected, sizeof(expected), "LATIN_1", 0, TRUE, U_ZERO_ERROR))
             log_err("u-> LATIN_1 is supposed to fail\n");
                 expected, sizeof(expected), "LATIN_1", 0, TRUE, U_ZERO_ERROR))
             log_err("u-> LATIN_1 is supposed to fail\n");
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected0, sizeof(expected0), "LATIN_1", 0, FALSE, U_ZERO_ERROR))
             log_err("u-> LATIN_1 is supposed to fail\n");
 
                 expected0, sizeof(expected0), "LATIN_1", 0, FALSE, U_ZERO_ERROR))
             log_err("u-> LATIN_1 is supposed to fail\n");
 
-        if(!convertFromU(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]),
+        if(!convertFromU(sampleText2, UPRV_LENGTHOF(sampleText2),
                 expected2, sizeof(expected2), "LATIN_1", 0, TRUE, U_ZERO_ERROR))
             log_err("u-> LATIN_1 did not match\n");
     }
                 expected2, sizeof(expected2), "LATIN_1", 0, TRUE, U_ZERO_ERROR))
             log_err("u-> LATIN_1 did not match\n");
     }
@@ -381,63 +385,63 @@ static void TestErrorBehaviour(){
         static const uint8_t expected3MBCS[] = { 0x01, 0xa2, 0xb4, 0xa1, 0xe0};
         static const int32_t offsets3MBCS[]        = { 0x00, 0x01, 0x01, 0x02, 0x02};
 
         static const uint8_t expected3MBCS[] = { 0x01, 0xa2, 0xb4, 0xa1, 0xe0};
         static const int32_t offsets3MBCS[]        = { 0x00, 0x01, 0x01, 0x02, 0x02};
 
-        static const UChar       sampleText4MBCS[] = { 0x0061, 0x00a6, 0xdc01};
+        static const UChar       sampleText4MBCS[] = { 0x0061, 0xFFE4, 0xdc01};
         static const uint8_t expected4MBCS[] = { 0x61, 0x8f, 0xa2, 0xc3, 0xf4, 0xfe};
         static const int32_t offsets4MBCS[]        = { 0x00, 0x01, 0x01, 0x01, 0x02, 0x02 };
 
         /*DBCS*/
         static const uint8_t expected4MBCS[] = { 0x61, 0x8f, 0xa2, 0xc3, 0xf4, 0xfe};
         static const int32_t offsets4MBCS[]        = { 0x00, 0x01, 0x01, 0x01, 0x02, 0x02 };
 
         /*DBCS*/
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expectedSUB, sizeof(expectedSUB), "ibm-1363", 0, TRUE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_DBCS portion] is supposed to fail\n");
                 expectedSUB, sizeof(expectedSUB), "ibm-1363", 0, TRUE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_DBCS portion] is supposed to fail\n");
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
-                expected, sizeof(expected), "ibm-1363", 0, FALSE, U_ZERO_ERROR))
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
+                expected, sizeof(expected), "ibm-1363", 0, FALSE, U_AMBIGUOUS_ALIAS_WARNING))
             log_err("u-> ibm-1363 [UCNV_DBCS portion] is supposed to fail\n");
 
             log_err("u-> ibm-1363 [UCNV_DBCS portion] is supposed to fail\n");
 
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expectedSUB, sizeof(expectedSUB), "ibm-1363", offsetsSUB, TRUE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_DBCS portion] is supposed to fail\n");
                 expectedSUB, sizeof(expectedSUB), "ibm-1363", offsetsSUB, TRUE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_DBCS portion] is supposed to fail\n");
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
-                expected, sizeof(expected), "ibm-1363", offsets, FALSE, U_ZERO_ERROR))
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
+                expected, sizeof(expected), "ibm-1363", offsets, FALSE, U_AMBIGUOUS_ALIAS_WARNING))
             log_err("u-> ibm-1363 [UCNV_DBCS portion] is supposed to fail\n");
 
         
             log_err("u-> ibm-1363 [UCNV_DBCS portion] is supposed to fail\n");
 
         
-        if(!convertFromU(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]),
+        if(!convertFromU(sampleText2, UPRV_LENGTHOF(sampleText2),
                 expected2, sizeof(expected2), "ibm-1363", 0, TRUE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_DBCS portion] did not match \n");
                 expected2, sizeof(expected2), "ibm-1363", 0, TRUE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_DBCS portion] did not match \n");
-        if(!convertFromU(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]),
+        if(!convertFromU(sampleText2, UPRV_LENGTHOF(sampleText2),
                 expected2, sizeof(expected2), "ibm-1363", offsets2, TRUE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_DBCS portion] did not match \n");
 
         /*MBCS*/
                 expected2, sizeof(expected2), "ibm-1363", offsets2, TRUE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_DBCS portion] did not match \n");
 
         /*MBCS*/
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expectedSUB, sizeof(expectedSUB), "ibm-1363", 0, TRUE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_MBCS] \n");
                 expectedSUB, sizeof(expectedSUB), "ibm-1363", 0, TRUE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_MBCS] \n");
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
-                expected, sizeof(expected), "ibm-1363", 0, FALSE, U_ZERO_ERROR))
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
+                expected, sizeof(expected), "ibm-1363", 0, FALSE, U_AMBIGUOUS_ALIAS_WARNING))
             log_err("u-> ibm-1363 [UCNV_MBCS] \n");
 
             log_err("u-> ibm-1363 [UCNV_MBCS] \n");
 
-        if(!convertFromU(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]),
+        if(!convertFromU(sampleText2, UPRV_LENGTHOF(sampleText2),
                 expected2, sizeof(expected2), "ibm-1363", 0, TRUE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_DBCS] did not match\n");
                 expected2, sizeof(expected2), "ibm-1363", 0, TRUE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_DBCS] did not match\n");
-        if(!convertFromU(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]),
+        if(!convertFromU(sampleText2, UPRV_LENGTHOF(sampleText2),
                 expected2, sizeof(expected2), "ibm-1363", 0, FALSE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_DBCS] did not match\n");
                 expected2, sizeof(expected2), "ibm-1363", 0, FALSE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_DBCS] did not match\n");
-        if(!convertFromU(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]),
+        if(!convertFromU(sampleText2, UPRV_LENGTHOF(sampleText2),
                 expected2, sizeof(expected2), "ibm-1363", offsets2, FALSE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_DBCS] did not match\n");
 
                 expected2, sizeof(expected2), "ibm-1363", offsets2, FALSE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_DBCS] did not match\n");
 
-        if(!convertFromU(sampleText3MBCS, sizeof(sampleText3MBCS)/sizeof(sampleText3MBCS[0]),
+        if(!convertFromU(sampleText3MBCS, UPRV_LENGTHOF(sampleText3MBCS),
                 expected3MBCS, sizeof(expected3MBCS), "ibm-1363", offsets3MBCS, TRUE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_MBCS] \n");
                 expected3MBCS, sizeof(expected3MBCS), "ibm-1363", offsets3MBCS, TRUE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_MBCS] \n");
-        if(!convertFromU(sampleText3MBCS, sizeof(sampleText3MBCS)/sizeof(sampleText3MBCS[0]),
+        if(!convertFromU(sampleText3MBCS, UPRV_LENGTHOF(sampleText3MBCS),
                 expected3MBCS, sizeof(expected3MBCS), "ibm-1363", offsets3MBCS, FALSE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_MBCS] \n");
 
                 expected3MBCS, sizeof(expected3MBCS), "ibm-1363", offsets3MBCS, FALSE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_MBCS] \n");
 
-        if(!convertFromU(sampleText4MBCS, sizeof(sampleText4MBCS)/sizeof(sampleText4MBCS[0]),
-                expected4MBCS, sizeof(expected4MBCS), "euc-jp", offsets4MBCS, TRUE, U_ZERO_ERROR))
+        if(!convertFromU(sampleText4MBCS, UPRV_LENGTHOF(sampleText4MBCS),
+                expected4MBCS, sizeof(expected4MBCS), "IBM-eucJP", offsets4MBCS, TRUE, U_ZERO_ERROR))
             log_err("u-> euc-jp [UCNV_MBCS] \n");
             log_err("u-> euc-jp [UCNV_MBCS] \n");
-        if(!convertFromU(sampleText4MBCS, sizeof(sampleText4MBCS)/sizeof(sampleText4MBCS[0]),
-                expected4MBCS, sizeof(expected4MBCS), "euc-jp", offsets4MBCS, FALSE, U_ZERO_ERROR))
+        if(!convertFromU(sampleText4MBCS, UPRV_LENGTHOF(sampleText4MBCS),
+                expected4MBCS, sizeof(expected4MBCS), "IBM-eucJP", offsets4MBCS, FALSE, U_ZERO_ERROR))
             log_err("u-> euc-jp [UCNV_MBCS] \n");
     }
 
             log_err("u-> euc-jp [UCNV_MBCS] \n");
     }
 
@@ -456,27 +460,27 @@ static void TestErrorBehaviour(){
         static const UChar       sampleText4MBCS[] = { 0x0061, 0x4e00, 0xdc01};
         static const uint8_t expected4MBCS[] = { 0x61, 0x1b, 0x24, 0x42, 0x30, 0x6c,0x1b,0x28,0x42,0x1a};
         static const int32_t offsets4MBCS[]        = { 0x00, 0x01, 0x01 ,0x01, 0x01, 0x01,0x02,0x02,0x02,0x02 };
         static const UChar       sampleText4MBCS[] = { 0x0061, 0x4e00, 0xdc01};
         static const uint8_t expected4MBCS[] = { 0x61, 0x1b, 0x24, 0x42, 0x30, 0x6c,0x1b,0x28,0x42,0x1a};
         static const int32_t offsets4MBCS[]        = { 0x00, 0x01, 0x01 ,0x01, 0x01, 0x01,0x02,0x02,0x02,0x02 };
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expectedSUB, sizeof(expectedSUB), "iso-2022-jp", offsets, TRUE, U_ZERO_ERROR))
             log_err("u-> iso-2022-jp [UCNV_MBCS] \n");
                 expectedSUB, sizeof(expectedSUB), "iso-2022-jp", offsets, TRUE, U_ZERO_ERROR))
             log_err("u-> iso-2022-jp [UCNV_MBCS] \n");
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
-                expected, sizeof(expected), "iso-2022-jp", offsets, FALSE, U_ZERO_ERROR))
-            log_err("u-> ibm-1363 [UCNV_MBCS] \n");
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
+                expected, sizeof(expected), "iso-2022-jp", offsets, FALSE, U_AMBIGUOUS_ALIAS_WARNING))
+            log_err("u-> iso-2022-jp [UCNV_MBCS] \n");
 
 
-        if(!convertFromU(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]),
+        if(!convertFromU(sampleText2, UPRV_LENGTHOF(sampleText2),
                 expected2, sizeof(expected2), "iso-2022-jp", offsets2, TRUE, U_ZERO_ERROR))
             log_err("u->iso-2022-jp[UCNV_DBCS] did not match\n");
                 expected2, sizeof(expected2), "iso-2022-jp", offsets2, TRUE, U_ZERO_ERROR))
             log_err("u->iso-2022-jp[UCNV_DBCS] did not match\n");
-        if(!convertFromU(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]),
+        if(!convertFromU(sampleText2, UPRV_LENGTHOF(sampleText2),
                 expected2, sizeof(expected2), "iso-2022-jp", offsets2, FALSE, U_ZERO_ERROR))
             log_err("u-> iso-2022-jp [UCNV_DBCS] did not match\n");
                 expected2, sizeof(expected2), "iso-2022-jp", offsets2, FALSE, U_ZERO_ERROR))
             log_err("u-> iso-2022-jp [UCNV_DBCS] did not match\n");
-        if(!convertFromU(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]),
+        if(!convertFromU(sampleText2, UPRV_LENGTHOF(sampleText2),
                 expected2, sizeof(expected2), "iso-2022-jp", offsets2, FALSE, U_ZERO_ERROR))
             log_err("u-> iso-2022-jp [UCNV_DBCS] did not match\n");
 
                 expected2, sizeof(expected2), "iso-2022-jp", offsets2, FALSE, U_ZERO_ERROR))
             log_err("u-> iso-2022-jp [UCNV_DBCS] did not match\n");
 
-        if(!convertFromU(sampleText4MBCS, sizeof(sampleText4MBCS)/sizeof(sampleText4MBCS[0]),
+        if(!convertFromU(sampleText4MBCS, UPRV_LENGTHOF(sampleText4MBCS),
                 expected4MBCS, sizeof(expected4MBCS), "iso-2022-jp", offsets4MBCS, TRUE, U_ZERO_ERROR))
             log_err("u-> iso-2022-jp [UCNV_MBCS] \n");
                 expected4MBCS, sizeof(expected4MBCS), "iso-2022-jp", offsets4MBCS, TRUE, U_ZERO_ERROR))
             log_err("u-> iso-2022-jp [UCNV_MBCS] \n");
-        if(!convertFromU(sampleText4MBCS, sizeof(sampleText4MBCS)/sizeof(sampleText4MBCS[0]),
+        if(!convertFromU(sampleText4MBCS, UPRV_LENGTHOF(sampleText4MBCS),
                 expected4MBCS, sizeof(expected4MBCS), "iso-2022-jp", offsets4MBCS, FALSE, U_ZERO_ERROR))
             log_err("u-> iso-2022-jp [UCNV_MBCS] \n");
     }
                 expected4MBCS, sizeof(expected4MBCS), "iso-2022-jp", offsets4MBCS, FALSE, U_ZERO_ERROR))
             log_err("u-> iso-2022-jp [UCNV_MBCS] \n");
     }
@@ -500,34 +504,34 @@ static void TestErrorBehaviour(){
         static const UChar       sampleText4MBCS[] = { 0x0061, 0x4e00, 0xdc01};
         static const uint8_t expected4MBCS[] = { 0x61, 0x1b, 0x24, 0x29, 0x41, 0x0e, 0x52, 0x3b, 0x0f, 0x1a };
         static const int32_t offsets4MBCS[]        = { 0x00, 0x01, 0x01 ,0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02 };
         static const UChar       sampleText4MBCS[] = { 0x0061, 0x4e00, 0xdc01};
         static const uint8_t expected4MBCS[] = { 0x61, 0x1b, 0x24, 0x29, 0x41, 0x0e, 0x52, 0x3b, 0x0f, 0x1a };
         static const int32_t offsets4MBCS[]        = { 0x00, 0x01, 0x01 ,0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02 };
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expectedSUB, sizeof(expectedSUB), "iso-2022-cn", offsets, TRUE, U_ZERO_ERROR))
             log_err("u-> iso-2022-cn [UCNV_MBCS] \n");
                 expectedSUB, sizeof(expectedSUB), "iso-2022-cn", offsets, TRUE, U_ZERO_ERROR))
             log_err("u-> iso-2022-cn [UCNV_MBCS] \n");
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected, sizeof(expected), "iso-2022-cn", offsets, FALSE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_MBCS] \n");
 
                 expected, sizeof(expected), "iso-2022-cn", offsets, FALSE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_MBCS] \n");
 
-        if(!convertFromU(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]),
+        if(!convertFromU(sampleText2, UPRV_LENGTHOF(sampleText2),
                 expected2, sizeof(expected2), "iso-2022-cn", offsets2, TRUE, U_ZERO_ERROR))
             log_err("u->iso-2022-cn[UCNV_DBCS] did not match\n");
                 expected2, sizeof(expected2), "iso-2022-cn", offsets2, TRUE, U_ZERO_ERROR))
             log_err("u->iso-2022-cn[UCNV_DBCS] did not match\n");
-        if(!convertFromU(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]),
+        if(!convertFromU(sampleText2, UPRV_LENGTHOF(sampleText2),
                 expected2, sizeof(expected2), "iso-2022-cn", offsets2, FALSE, U_ZERO_ERROR))
             log_err("u-> iso-2022-cn [UCNV_DBCS] did not match\n");
                 expected2, sizeof(expected2), "iso-2022-cn", offsets2, FALSE, U_ZERO_ERROR))
             log_err("u-> iso-2022-cn [UCNV_DBCS] did not match\n");
-        if(!convertFromU(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]),
+        if(!convertFromU(sampleText2, UPRV_LENGTHOF(sampleText2),
                 expected2, sizeof(expected2), "iso-2022-cn", offsets2, FALSE, U_ZERO_ERROR))
             log_err("u-> iso-2022-cn [UCNV_DBCS] did not match\n");
 
                 expected2, sizeof(expected2), "iso-2022-cn", offsets2, FALSE, U_ZERO_ERROR))
             log_err("u-> iso-2022-cn [UCNV_DBCS] did not match\n");
 
-        if(!convertFromU(sampleText3MBCS, sizeof(sampleText3MBCS)/sizeof(sampleText3MBCS[0]),
+        if(!convertFromU(sampleText3MBCS, UPRV_LENGTHOF(sampleText3MBCS),
                 expected3MBCS, sizeof(expected3MBCS), "iso-2022-cn", offsets3MBCS, TRUE, U_ZERO_ERROR))
             log_err("u->iso-2022-cn [UCNV_MBCS] \n");
                 expected3MBCS, sizeof(expected3MBCS), "iso-2022-cn", offsets3MBCS, TRUE, U_ZERO_ERROR))
             log_err("u->iso-2022-cn [UCNV_MBCS] \n");
-        if(!convertFromU(sampleText3MBCS, sizeof(sampleText3MBCS)/sizeof(sampleText3MBCS[0]),
+        if(!convertFromU(sampleText3MBCS, UPRV_LENGTHOF(sampleText3MBCS),
                 expected3MBCS, sizeof(expected3MBCS), "iso-2022-cn", offsets3MBCS, FALSE, U_ZERO_ERROR))
             log_err("u-> iso-2022-cn[UCNV_MBCS] \n");
 
                 expected3MBCS, sizeof(expected3MBCS), "iso-2022-cn", offsets3MBCS, FALSE, U_ZERO_ERROR))
             log_err("u-> iso-2022-cn[UCNV_MBCS] \n");
 
-        if(!convertFromU(sampleText4MBCS, sizeof(sampleText4MBCS)/sizeof(sampleText4MBCS[0]),
+        if(!convertFromU(sampleText4MBCS, UPRV_LENGTHOF(sampleText4MBCS),
                 expected4MBCS, sizeof(expected4MBCS), "iso-2022-cn", offsets4MBCS, TRUE, U_ZERO_ERROR))
             log_err("u-> iso-2022-cn [UCNV_MBCS] \n");
                 expected4MBCS, sizeof(expected4MBCS), "iso-2022-cn", offsets4MBCS, TRUE, U_ZERO_ERROR))
             log_err("u-> iso-2022-cn [UCNV_MBCS] \n");
-        if(!convertFromU(sampleText4MBCS, sizeof(sampleText4MBCS)/sizeof(sampleText4MBCS[0]),
+        if(!convertFromU(sampleText4MBCS, UPRV_LENGTHOF(sampleText4MBCS),
                 expected4MBCS, sizeof(expected4MBCS), "iso-2022-cn", offsets4MBCS, FALSE, U_ZERO_ERROR))
             log_err("u-> iso-2022-cn [UCNV_MBCS] \n");
     }
                 expected4MBCS, sizeof(expected4MBCS), "iso-2022-cn", offsets4MBCS, FALSE, U_ZERO_ERROR))
             log_err("u-> iso-2022-cn [UCNV_MBCS] \n");
     }
@@ -548,27 +552,27 @@ static void TestErrorBehaviour(){
         static const uint8_t expected3MBCS[] = { 0x1b, 0x24, 0x29, 0x43,  0x51, 0x50, 0x1A };
         static const int32_t offsets3MBCS[]        = { -1,   -1,   -1,   -1,    0x00, 0x01, 0x02, 0x02 };
 
         static const uint8_t expected3MBCS[] = { 0x1b, 0x24, 0x29, 0x43,  0x51, 0x50, 0x1A };
         static const int32_t offsets3MBCS[]        = { -1,   -1,   -1,   -1,    0x00, 0x01, 0x02, 0x02 };
 
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expectedSUB, sizeof(expectedSUB), "iso-2022-kr", offsets, TRUE, U_ZERO_ERROR))
             log_err("u-> iso-2022-kr [UCNV_MBCS] \n");
                 expectedSUB, sizeof(expectedSUB), "iso-2022-kr", offsets, TRUE, U_ZERO_ERROR))
             log_err("u-> iso-2022-kr [UCNV_MBCS] \n");
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected, sizeof(expected), "iso-2022-kr", offsets, FALSE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_MBCS] \n");
 
                 expected, sizeof(expected), "iso-2022-kr", offsets, FALSE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_MBCS] \n");
 
-        if(!convertFromU(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]),
+        if(!convertFromU(sampleText2, UPRV_LENGTHOF(sampleText2),
                 expected2, sizeof(expected2), "iso-2022-kr", offsets2, TRUE, U_ZERO_ERROR))
             log_err("u->iso-2022-kr[UCNV_DBCS] did not match\n");
                 expected2, sizeof(expected2), "iso-2022-kr", offsets2, TRUE, U_ZERO_ERROR))
             log_err("u->iso-2022-kr[UCNV_DBCS] did not match\n");
-        if(!convertFromU(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]),
+        if(!convertFromU(sampleText2, UPRV_LENGTHOF(sampleText2),
                 expected2, sizeof(expected2), "iso-2022-kr", offsets2, FALSE, U_ZERO_ERROR))
             log_err("u-> iso-2022-kr [UCNV_DBCS] did not match\n");
                 expected2, sizeof(expected2), "iso-2022-kr", offsets2, FALSE, U_ZERO_ERROR))
             log_err("u-> iso-2022-kr [UCNV_DBCS] did not match\n");
-        if(!convertFromU(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]),
+        if(!convertFromU(sampleText2, UPRV_LENGTHOF(sampleText2),
                 expected2, sizeof(expected2), "iso-2022-kr", offsets2, FALSE, U_ZERO_ERROR))
             log_err("u-> iso-2022-kr [UCNV_DBCS] did not match\n");
 
                 expected2, sizeof(expected2), "iso-2022-kr", offsets2, FALSE, U_ZERO_ERROR))
             log_err("u-> iso-2022-kr [UCNV_DBCS] did not match\n");
 
-        if(!convertFromU(sampleText3MBCS, sizeof(sampleText3MBCS)/sizeof(sampleText3MBCS[0]),
+        if(!convertFromU(sampleText3MBCS, UPRV_LENGTHOF(sampleText3MBCS),
                 expected3MBCS, sizeof(expected3MBCS), "iso-2022-kr", offsets3MBCS, TRUE, U_ZERO_ERROR))
             log_err("u->iso-2022-kr [UCNV_MBCS] \n");
                 expected3MBCS, sizeof(expected3MBCS), "iso-2022-kr", offsets3MBCS, TRUE, U_ZERO_ERROR))
             log_err("u->iso-2022-kr [UCNV_MBCS] \n");
-        if(!convertFromU(sampleText3MBCS, sizeof(sampleText3MBCS)/sizeof(sampleText3MBCS[0]),
+        if(!convertFromU(sampleText3MBCS, UPRV_LENGTHOF(sampleText3MBCS),
                 expected3MBCS, sizeof(expected3MBCS), "iso-2022-kr", offsets3MBCS, FALSE, U_ZERO_ERROR))
             log_err("u-> iso-2022-kr[UCNV_MBCS] \n");
     }
                 expected3MBCS, sizeof(expected3MBCS), "iso-2022-kr", offsets3MBCS, FALSE, U_ZERO_ERROR))
             log_err("u-> iso-2022-kr[UCNV_MBCS] \n");
     }
@@ -592,34 +596,34 @@ static void TestErrorBehaviour(){
         static const UChar       sampleText4MBCS[] = { 0x0061, 0x4e00, 0xdc01};
         static const uint8_t expected4MBCS[] = { 0x7e, 0x7d, 0x61, 0x7e, 0x7b, 0x52, 0x3b, 0x7e, 0x7d, 0x1a };
         static const int32_t offsets4MBCS[]        = { 0x00, 0x00, 0x00, 0x01, 0x01, 0x01 ,0x01, 0x02, 0x02, 0x02 };
         static const UChar       sampleText4MBCS[] = { 0x0061, 0x4e00, 0xdc01};
         static const uint8_t expected4MBCS[] = { 0x7e, 0x7d, 0x61, 0x7e, 0x7b, 0x52, 0x3b, 0x7e, 0x7d, 0x1a };
         static const int32_t offsets4MBCS[]        = { 0x00, 0x00, 0x00, 0x01, 0x01, 0x01 ,0x01, 0x02, 0x02, 0x02 };
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expectedSUB, sizeof(expectedSUB), "HZ", offsets, TRUE, U_ZERO_ERROR))
             log_err("u-> HZ [UCNV_MBCS] \n");
                 expectedSUB, sizeof(expectedSUB), "HZ", offsets, TRUE, U_ZERO_ERROR))
             log_err("u-> HZ [UCNV_MBCS] \n");
-        if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!convertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected, sizeof(expected), "HZ", offsets, FALSE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_MBCS] \n");
 
                 expected, sizeof(expected), "HZ", offsets, FALSE, U_ZERO_ERROR))
             log_err("u-> ibm-1363 [UCNV_MBCS] \n");
 
-        if(!convertFromU(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]),
+        if(!convertFromU(sampleText2, UPRV_LENGTHOF(sampleText2),
                 expected2, sizeof(expected2), "HZ", offsets2, TRUE, U_ZERO_ERROR))
             log_err("u->HZ[UCNV_DBCS] did not match\n");
                 expected2, sizeof(expected2), "HZ", offsets2, TRUE, U_ZERO_ERROR))
             log_err("u->HZ[UCNV_DBCS] did not match\n");
-        if(!convertFromU(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]),
+        if(!convertFromU(sampleText2, UPRV_LENGTHOF(sampleText2),
                 expected2, sizeof(expected2), "HZ", offsets2, FALSE, U_ZERO_ERROR))
             log_err("u-> HZ [UCNV_DBCS] did not match\n");
                 expected2, sizeof(expected2), "HZ", offsets2, FALSE, U_ZERO_ERROR))
             log_err("u-> HZ [UCNV_DBCS] did not match\n");
-        if(!convertFromU(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]),
+        if(!convertFromU(sampleText2, UPRV_LENGTHOF(sampleText2),
                 expected2, sizeof(expected2), "HZ", offsets2, FALSE, U_ZERO_ERROR))
             log_err("u-> HZ [UCNV_DBCS] did not match\n");
 
                 expected2, sizeof(expected2), "HZ", offsets2, FALSE, U_ZERO_ERROR))
             log_err("u-> HZ [UCNV_DBCS] did not match\n");
 
-        if(!convertFromU(sampleText3MBCS, sizeof(sampleText3MBCS)/sizeof(sampleText3MBCS[0]),
+        if(!convertFromU(sampleText3MBCS, UPRV_LENGTHOF(sampleText3MBCS),
                 expected3MBCS, sizeof(expected3MBCS), "HZ", offsets3MBCS, TRUE, U_ZERO_ERROR))
             log_err("u->HZ [UCNV_MBCS] \n");
                 expected3MBCS, sizeof(expected3MBCS), "HZ", offsets3MBCS, TRUE, U_ZERO_ERROR))
             log_err("u->HZ [UCNV_MBCS] \n");
-        if(!convertFromU(sampleText3MBCS, sizeof(sampleText3MBCS)/sizeof(sampleText3MBCS[0]),
+        if(!convertFromU(sampleText3MBCS, UPRV_LENGTHOF(sampleText3MBCS),
                 expected3MBCS, sizeof(expected3MBCS), "HZ", offsets3MBCS, FALSE, U_ZERO_ERROR))
             log_err("u-> HZ[UCNV_MBCS] \n");
 
                 expected3MBCS, sizeof(expected3MBCS), "HZ", offsets3MBCS, FALSE, U_ZERO_ERROR))
             log_err("u-> HZ[UCNV_MBCS] \n");
 
-        if(!convertFromU(sampleText4MBCS, sizeof(sampleText4MBCS)/sizeof(sampleText4MBCS[0]),
+        if(!convertFromU(sampleText4MBCS, UPRV_LENGTHOF(sampleText4MBCS),
                 expected4MBCS, sizeof(expected4MBCS), "HZ", offsets4MBCS, TRUE, U_ZERO_ERROR))
             log_err("u-> HZ [UCNV_MBCS] \n");
                 expected4MBCS, sizeof(expected4MBCS), "HZ", offsets4MBCS, TRUE, U_ZERO_ERROR))
             log_err("u-> HZ [UCNV_MBCS] \n");
-        if(!convertFromU(sampleText4MBCS, sizeof(sampleText4MBCS)/sizeof(sampleText4MBCS[0]),
+        if(!convertFromU(sampleText4MBCS, UPRV_LENGTHOF(sampleText4MBCS),
                 expected4MBCS, sizeof(expected4MBCS), "HZ", offsets4MBCS, FALSE, U_ZERO_ERROR))
             log_err("u-> HZ [UCNV_MBCS] \n");
     }
                 expected4MBCS, sizeof(expected4MBCS), "HZ", offsets4MBCS, FALSE, U_ZERO_ERROR))
             log_err("u-> HZ [UCNV_MBCS] \n");
     }
@@ -636,10 +640,10 @@ static void TestToUnicodeErrorBehaviour()
         const UChar expected[] = { 0x00a1 };
         
         if(!convertToU(sampleText, sizeof(sampleText), 
         const UChar expected[] = { 0x00a1 };
         
         if(!convertToU(sampleText, sizeof(sampleText), 
-                expected, sizeof(expected)/sizeof(expected[0]), "ibm-1363", 0, TRUE, U_ZERO_ERROR ))
+                expected, UPRV_LENGTHOF(expected), "ibm-1363", 0, TRUE, U_AMBIGUOUS_ALIAS_WARNING ))
             log_err("DBCS (ibm-1363)->Unicode  did not match.\n");
         if(!convertToU(sampleText, sizeof(sampleText), 
             log_err("DBCS (ibm-1363)->Unicode  did not match.\n");
         if(!convertToU(sampleText, sizeof(sampleText), 
-                expected, sizeof(expected)/sizeof(expected[0]), "ibm-1363", 0, FALSE, U_ZERO_ERROR ))
+                expected, UPRV_LENGTHOF(expected), "ibm-1363", 0, FALSE, U_AMBIGUOUS_ALIAS_WARNING ))
             log_err("DBCS (ibm-1363)->Unicode  with flush = false did not match.\n");
     }
     log_verbose("Testing error conditions for SBCS\n");
             log_err("DBCS (ibm-1363)->Unicode  with flush = false did not match.\n");
     }
     log_verbose("Testing error conditions for SBCS\n");
@@ -651,10 +655,10 @@ static void TestToUnicodeErrorBehaviour()
         const UChar expected2[] = { 0x0073 };*/
 
         if(!convertToU(sampleText, sizeof(sampleText), 
         const UChar expected2[] = { 0x0073 };*/
 
         if(!convertToU(sampleText, sizeof(sampleText), 
-                expected, sizeof(expected)/sizeof(expected[0]), "ibm-1051", 0, TRUE, U_ZERO_ERROR ))
+                expected, UPRV_LENGTHOF(expected), "ibm-1051", 0, TRUE, U_ZERO_ERROR ))
             log_err("SBCS (ibm-1051)->Unicode  did not match.\n");
         if(!convertToU(sampleText, sizeof(sampleText), 
             log_err("SBCS (ibm-1051)->Unicode  did not match.\n");
         if(!convertToU(sampleText, sizeof(sampleText), 
-                expected, sizeof(expected)/sizeof(expected[0]), "ibm-1051", 0, FALSE, U_ZERO_ERROR ))
+                expected, UPRV_LENGTHOF(expected), "ibm-1051", 0, FALSE, U_ZERO_ERROR ))
             log_err("SBCS (ibm-1051)->Unicode  with flush = false did not match.\n");
 
     }
             log_err("SBCS (ibm-1051)->Unicode  with flush = false did not match.\n");
 
     }
@@ -701,8 +705,8 @@ static void TestRegressionUTF8(){
             if (currCh == SURROGATE_HIGH_START) {
                 currCh = SURROGATE_LOW_END + 1; /* Skip surrogate range */
             }
             if (currCh == SURROGATE_HIGH_START) {
                 currCh = SURROGATE_LOW_END + 1; /* Skip surrogate range */
             }
-            UTF16_APPEND_CHAR_SAFE(standardForm, offset16, MAX_LENGTH, currCh);
-            UTF8_APPEND_CHAR_SAFE(utf8, offset8, MAX_LENGTH, currCh);
+            U16_APPEND_UNSAFE(standardForm, offset16, currCh);
+            U8_APPEND_UNSAFE(utf8, offset8, currCh);
             currCh++;
         }
         if(!convertFromU(standardForm, offset16, 
             currCh++;
         }
         if(!convertFromU(standardForm, offset16, 
@@ -755,6 +759,7 @@ static void TestRegressionUTF8(){
 #define MAX_UTF32_LEN 1
 
 static void TestRegressionUTF32(){
 #define MAX_UTF32_LEN 1
 
 static void TestRegressionUTF32(){
+#if !UCONFIG_ONLY_HTML_CONVERSION
     UChar32 currCh = 0;
     int32_t offset32;
     int32_t offset16;
     UChar32 currCh = 0;
     int32_t offset32;
     int32_t offset16;
@@ -771,8 +776,8 @@ static void TestRegressionUTF32(){
             if (currCh == SURROGATE_HIGH_START) {
                 currCh = SURROGATE_LOW_END + 1; /* Skip surrogate range */
             }
             if (currCh == SURROGATE_HIGH_START) {
                 currCh = SURROGATE_LOW_END + 1; /* Skip surrogate range */
             }
-            UTF16_APPEND_CHAR_SAFE(standardForm, offset16, MAX_LENGTH, currCh);
-            UTF32_APPEND_CHAR_SAFE(utf32, offset32, MAX_LENGTH, currCh);
+            U16_APPEND_UNSAFE(standardForm, offset16, currCh);
+            utf32[offset32++] = currCh;
             currCh++;
         }
         if(!convertFromU(standardForm, offset16, 
             currCh++;
         }
         if(!convertFromU(standardForm, offset16, 
@@ -807,17 +812,17 @@ static void TestRegressionUTF32(){
             0x02, 0x02, 0x02, 0x02
         };
 
             0x02, 0x02, 0x02, 0x02
         };
 
-        if(!convertFromU(sampleBadStartSurrogate, sizeof(sampleBadStartSurrogate)/sizeof(sampleBadStartSurrogate[0]),
+        if(!convertFromU(sampleBadStartSurrogate, UPRV_LENGTHOF(sampleBadStartSurrogate),
                 expectedUTF32BE, sizeof(expectedUTF32BE), "UTF-32BE", offsetsUTF32, TRUE, U_ZERO_ERROR))
             log_err("u->UTF-32BE\n");
                 expectedUTF32BE, sizeof(expectedUTF32BE), "UTF-32BE", offsetsUTF32, TRUE, U_ZERO_ERROR))
             log_err("u->UTF-32BE\n");
-        if(!convertFromU(sampleBadEndSurrogate, sizeof(sampleBadEndSurrogate)/sizeof(sampleBadEndSurrogate[0]),
+        if(!convertFromU(sampleBadEndSurrogate, UPRV_LENGTHOF(sampleBadEndSurrogate),
                 expectedUTF32BE, sizeof(expectedUTF32BE), "UTF-32BE", offsetsUTF32, TRUE, U_ZERO_ERROR))
             log_err("u->UTF-32BE\n");
 
                 expectedUTF32BE, sizeof(expectedUTF32BE), "UTF-32BE", offsetsUTF32, TRUE, U_ZERO_ERROR))
             log_err("u->UTF-32BE\n");
 
-        if(!convertFromU(sampleBadStartSurrogate, sizeof(sampleBadStartSurrogate)/sizeof(sampleBadStartSurrogate[0]),
+        if(!convertFromU(sampleBadStartSurrogate, UPRV_LENGTHOF(sampleBadStartSurrogate),
                 expectedUTF32LE, sizeof(expectedUTF32LE), "UTF-32LE", offsetsUTF32, TRUE, U_ZERO_ERROR))
             log_err("u->UTF-32LE\n");
                 expectedUTF32LE, sizeof(expectedUTF32LE), "UTF-32LE", offsetsUTF32, TRUE, U_ZERO_ERROR))
             log_err("u->UTF-32LE\n");
-        if(!convertFromU(sampleBadEndSurrogate, sizeof(sampleBadEndSurrogate)/sizeof(sampleBadEndSurrogate[0]),
+        if(!convertFromU(sampleBadEndSurrogate, UPRV_LENGTHOF(sampleBadEndSurrogate),
                 expectedUTF32LE, sizeof(expectedUTF32LE), "UTF-32LE", offsetsUTF32, TRUE, U_ZERO_ERROR))
             log_err("u->UTF-32LE\n");
     }
                 expectedUTF32LE, sizeof(expectedUTF32LE), "UTF-32LE", offsetsUTF32, TRUE, U_ZERO_ERROR))
             log_err("u->UTF-32LE\n");
     }
@@ -886,6 +891,7 @@ static void TestRegressionUTF32(){
         }
         ucnv_close(convLE);
     }
         }
         ucnv_close(convLE);
     }
+#endif
 }
 
 /*Walk through the available converters*/
 }
 
 /*Walk through the available converters*/
@@ -930,7 +936,7 @@ static void TestWithBufferSize(int32_t insize, int32_t outsize){
             { 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0007, 0x000a, 0x000d };*/
 
         /*UTF-8*/
             { 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0007, 0x000a, 0x000d };*/
 
         /*UTF-8*/
-        if(!testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!testConvertFromU(sampleText, UPRV_LENGTHOF(sampleText),
             expectedUTF8, sizeof(expectedUTF8), "UTF8", UCNV_FROM_U_CALLBACK_SUBSTITUTE, toUTF8Offs ,FALSE))
              log_err("u-> UTF8 did not match.\n");
     }
             expectedUTF8, sizeof(expectedUTF8), "UTF8", UCNV_FROM_U_CALLBACK_SUBSTITUTE, toUTF8Offs ,FALSE))
              log_err("u-> UTF8 did not match.\n");
     }
@@ -946,7 +952,7 @@ static void TestWithBufferSize(int32_t insize, int32_t outsize){
             0x61 };
         int32_t offset[]= {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 4};
 
             0x61 };
         int32_t offset[]= {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 4};
 
-        if(!testConvertFromU(inputTest, sizeof(inputTest)/sizeof(inputTest[0]),
+        if(!testConvertFromU(inputTest, UPRV_LENGTHOF(inputTest),
                 toIBM943, sizeof(toIBM943), "ibm-943",
                 (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_ESCAPE, offset,FALSE))
             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,FALSE))
             log_err("u-> ibm-943 with subst with value did not match.\n");
@@ -957,11 +963,11 @@ static void TestWithBufferSize(int32_t insize, int32_t outsize){
     {
         const uint8_t sampleText1[] = { 0x31, 0xe4, 0xba, 0x8c, 
             0xe0, 0x80,  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};
+        UChar    expected1[] = {  0x0031, 0x4e8c, 0xfffd, 0xfffd, 0x0061};
+        int32_t offsets1[] = {   0x0000, 0x0001, 0x0004, 0x0005, 0x0006};
 
         if(!testConvertToU(sampleText1, sizeof(sampleText1),
 
         if(!testConvertToU(sampleText1, sizeof(sampleText1),
-                 expected1, sizeof(expected1)/sizeof(expected1[0]),"utf8", UCNV_TO_U_CALLBACK_SUBSTITUTE, offsets1,FALSE))
+                 expected1, UPRV_LENGTHOF(expected1),"utf8", UCNV_TO_U_CALLBACK_SUBSTITUTE, offsets1,FALSE))
             log_err("utf8->u with substitute did not match.\n");;
     }
 
             log_err("utf8->u with substitute did not match.\n");;
     }
 
@@ -978,7 +984,7 @@ static void TestWithBufferSize(int32_t insize, int32_t outsize){
         int32_t  fromIBM943Offs [] =    { 0, 1, 3, 3, 3, 3, 3, 3, 3, 3, 5};
 
         if(!testConvertToU(sampleTxtToU, sizeof(sampleTxtToU),
         int32_t  fromIBM943Offs [] =    { 0, 1, 3, 3, 3, 3, 3, 3, 3, 3, 5};
 
         if(!testConvertToU(sampleTxtToU, sizeof(sampleTxtToU),
-                 IBM_943toUnicode, sizeof(IBM_943toUnicode)/sizeof(IBM_943toUnicode[0]),"ibm-943",
+                 IBM_943toUnicode, UPRV_LENGTHOF(IBM_943toUnicode),"ibm-943",
                 (UConverterToUCallback)UCNV_TO_U_CALLBACK_ESCAPE, fromIBM943Offs,FALSE))
             log_err("ibm-943->u with substitute with value did not match.\n");
 
                 (UConverterToUCallback)UCNV_TO_U_CALLBACK_ESCAPE, fromIBM943Offs,FALSE))
             log_err("ibm-943->u with substitute with value did not match.\n");
 
@@ -1223,7 +1229,7 @@ static UBool testConvertFromU( const UChar *source, int sourceLen,  const uint8_
     targ = junkout;
     offs = junokout;
 
     targ = junkout;
     offs = junokout;
 
-    realBufferSize = (sizeof(junkout)/sizeof(junkout[0]));
+    realBufferSize = UPRV_LENGTHOF(junkout);
     realBufferEnd = junkout + realBufferSize;
     realSourceEnd = source + sourceLen;
 
     realBufferEnd = junkout + realBufferSize;
     realSourceEnd = source + sourceLen;
 
@@ -1273,7 +1279,7 @@ static UBool testConvertFromU( const UChar *source, int sourceLen,  const uint8_
 
     log_verbose("\nConversion done [%d uchars in -> %d chars out]. \nResult :",
         sourceLen, targ-junkout);
 
     log_verbose("\nConversion done [%d uchars in -> %d chars out]. \nResult :",
         sourceLen, targ-junkout);
-    if(VERBOSITY)
+    if(getTestOption(VERBOSITY_OPTION))
     {
         char junk[999];
         char offset_str[999];
     {
         char junk[999];
         char offset_str[999];
@@ -1397,7 +1403,7 @@ static UBool testConvertToU( const uint8_t *source, int sourcelen, const UChar *
     targ = junkout;
     offs = junokout;
     
     targ = junkout;
     offs = junokout;
     
-    realBufferSize = (sizeof(junkout)/sizeof(junkout[0]));
+    realBufferSize = UPRV_LENGTHOF(junkout);
     realBufferEnd = junkout + realBufferSize;
     realSourceEnd = src + sourcelen;
 
     realBufferEnd = junkout + realBufferSize;
     realSourceEnd = src + sourcelen;
 
@@ -1448,7 +1454,7 @@ static UBool testConvertToU( const uint8_t *source, int sourcelen, const UChar *
 
     log_verbose("\nConversion done. %d bytes -> %d chars.\nResult :",
         sourcelen, targ-junkout);
 
     log_verbose("\nConversion done. %d bytes -> %d chars.\nResult :",
         sourcelen, targ-junkout);
-    if(VERBOSITY)
+    if(getTestOption(VERBOSITY_OPTION))
     {
         char junk[999];
         char offset_str[999];
     {
         char junk[999];
         char offset_str[999];
@@ -1528,27 +1534,27 @@ static void TestResetBehaviour(void){
         static const int32_t offsets1[] =  { 0,2,4,6};
 
         /*DBCS*/
         static const int32_t offsets1[] =  { 0,2,4,6};
 
         /*DBCS*/
-        if(!testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!testConvertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected, sizeof(expected), "ibm-1363", UCNV_FROM_U_CALLBACK_SUBSTITUTE , NULL, TRUE))
             log_err("u-> ibm-1363 [UCNV_DBCS portion] not match.\n");
                 expected, sizeof(expected), "ibm-1363", UCNV_FROM_U_CALLBACK_SUBSTITUTE , NULL, TRUE))
             log_err("u-> ibm-1363 [UCNV_DBCS portion] not match.\n");
-        if(!testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!testConvertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected, sizeof(expected), "ibm-1363", UCNV_FROM_U_CALLBACK_SUBSTITUTE,offsets , TRUE))
             log_err("u-> ibm-1363 [UCNV_DBCS portion] not match.\n");
        
         if(!testConvertToU(expected1, sizeof(expected1), 
                 expected, sizeof(expected), "ibm-1363", UCNV_FROM_U_CALLBACK_SUBSTITUTE,offsets , TRUE))
             log_err("u-> ibm-1363 [UCNV_DBCS portion] not match.\n");
        
         if(!testConvertToU(expected1, sizeof(expected1), 
-                sampleText1, sizeof(sampleText1)/sizeof(sampleText1[0]), "ibm-1363",UCNV_TO_U_CALLBACK_SUBSTITUTE , 
+                sampleText1, UPRV_LENGTHOF(sampleText1), "ibm-1363",UCNV_TO_U_CALLBACK_SUBSTITUTE , 
                 offsets1, TRUE))
            log_err("ibm-1363 -> did not match.\n");
         /*MBCS*/
                 offsets1, TRUE))
            log_err("ibm-1363 -> did not match.\n");
         /*MBCS*/
-        if(!testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!testConvertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected, sizeof(expected), "ibm-1363", UCNV_FROM_U_CALLBACK_SUBSTITUTE , NULL, TRUE))
             log_err("u-> ibm-1363 [UCNV_MBCS] not match.\n");
                 expected, sizeof(expected), "ibm-1363", UCNV_FROM_U_CALLBACK_SUBSTITUTE , NULL, TRUE))
             log_err("u-> ibm-1363 [UCNV_MBCS] not match.\n");
-        if(!testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!testConvertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected, sizeof(expected), "ibm-1363", UCNV_FROM_U_CALLBACK_SUBSTITUTE,offsets , TRUE))
             log_err("u-> ibm-1363 [UCNV_MBCS] not match.\n");
       
         if(!testConvertToU(expected1, sizeof(expected1), 
                 expected, sizeof(expected), "ibm-1363", UCNV_FROM_U_CALLBACK_SUBSTITUTE,offsets , TRUE))
             log_err("u-> ibm-1363 [UCNV_MBCS] not match.\n");
       
         if(!testConvertToU(expected1, sizeof(expected1), 
-                sampleText1, sizeof(sampleText1)/sizeof(sampleText1[0]), "ibm-1363",UCNV_TO_U_CALLBACK_SUBSTITUTE , 
+                sampleText1, UPRV_LENGTHOF(sampleText1), "ibm-1363",UCNV_TO_U_CALLBACK_SUBSTITUTE , 
                 offsets1, TRUE))
            log_err("ibm-1363 -> did not match.\n");
 
                 offsets1, TRUE))
            log_err("ibm-1363 -> did not match.\n");
 
@@ -1571,15 +1577,15 @@ static void TestResetBehaviour(void){
         static const int32_t offsets1[] =  { 3,5,10,11,12};
 
         /*iso-2022-jp*/
         static const int32_t offsets1[] =  { 3,5,10,11,12};
 
         /*iso-2022-jp*/
-        if(!testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!testConvertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected, sizeof(expected), "iso-2022-jp",  UCNV_FROM_U_CALLBACK_SUBSTITUTE , NULL, TRUE))
             log_err("u-> not match.\n");
                 expected, sizeof(expected), "iso-2022-jp",  UCNV_FROM_U_CALLBACK_SUBSTITUTE , NULL, TRUE))
             log_err("u-> not match.\n");
-        if(!testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!testConvertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected, sizeof(expected), "iso-2022-jp", UCNV_FROM_U_CALLBACK_SUBSTITUTE,offsets , TRUE))
             log_err("u->  not match.\n");
         
         if(!testConvertToU(expected1, sizeof(expected1), 
                 expected, sizeof(expected), "iso-2022-jp", UCNV_FROM_U_CALLBACK_SUBSTITUTE,offsets , TRUE))
             log_err("u->  not match.\n");
         
         if(!testConvertToU(expected1, sizeof(expected1), 
-                sampleText1, sizeof(sampleText1)/sizeof(sampleText1[0]), "iso-2022-jp",UCNV_TO_U_CALLBACK_SUBSTITUTE ,
+                sampleText1, UPRV_LENGTHOF(sampleText1), "iso-2022-jp",UCNV_TO_U_CALLBACK_SUBSTITUTE ,
                 offsets1, TRUE))
            log_err("iso-2022-jp -> did not match.\n");
 
                 offsets1, TRUE))
            log_err("iso-2022-jp -> did not match.\n");
 
@@ -1616,15 +1622,15 @@ static void TestResetBehaviour(void){
         static const int32_t offsets1[] =  { 5,7,13,16,17};
 
         /*iso-2022-CN*/
         static const int32_t offsets1[] =  { 5,7,13,16,17};
 
         /*iso-2022-CN*/
-        if(!testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!testConvertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected, sizeof(expected), "iso-2022-cn", UCNV_FROM_U_CALLBACK_SUBSTITUTE , NULL, TRUE))
             log_err("u-> not match.\n");
                 expected, sizeof(expected), "iso-2022-cn", UCNV_FROM_U_CALLBACK_SUBSTITUTE , NULL, TRUE))
             log_err("u-> not match.\n");
-        if(!testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!testConvertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected, sizeof(expected), "iso-2022-cn", UCNV_FROM_U_CALLBACK_SUBSTITUTE,offsets , TRUE))
             log_err("u-> not match.\n");
 
         if(!testConvertToU(expected1, sizeof(expected1), 
                 expected, sizeof(expected), "iso-2022-cn", UCNV_FROM_U_CALLBACK_SUBSTITUTE,offsets , TRUE))
             log_err("u-> not match.\n");
 
         if(!testConvertToU(expected1, sizeof(expected1), 
-                sampleText1, sizeof(sampleText1)/sizeof(sampleText1[0]), "iso-2022-cn",UCNV_TO_U_CALLBACK_SUBSTITUTE ,
+                sampleText1, UPRV_LENGTHOF(sampleText1), "iso-2022-cn",UCNV_TO_U_CALLBACK_SUBSTITUTE ,
                 offsets1, TRUE))
            log_err("iso-2022-cn -> did not match.\n");
     }
                 offsets1, TRUE))
            log_err("iso-2022-cn -> did not match.\n");
     }
@@ -1665,14 +1671,14 @@ static void TestResetBehaviour(void){
                       
                             };
         /*iso-2022-kr*/
                       
                             };
         /*iso-2022-kr*/
-        if(!testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!testConvertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected, sizeof(expected), "iso-2022-kr",  UCNV_FROM_U_CALLBACK_SUBSTITUTE , NULL, TRUE))
             log_err("u-> iso-2022-kr [UCNV_DBCS] not match.\n");
                 expected, sizeof(expected), "iso-2022-kr",  UCNV_FROM_U_CALLBACK_SUBSTITUTE , NULL, TRUE))
             log_err("u-> iso-2022-kr [UCNV_DBCS] not match.\n");
-        if(!testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!testConvertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected, sizeof(expected), "iso-2022-kr",  UCNV_FROM_U_CALLBACK_SUBSTITUTE,offsets , TRUE))
             log_err("u-> iso-2022-kr [UCNV_DBCS] not match.\n");
         if(!testConvertToU(expected1, sizeof(expected1), 
                 expected, sizeof(expected), "iso-2022-kr",  UCNV_FROM_U_CALLBACK_SUBSTITUTE,offsets , TRUE))
             log_err("u-> iso-2022-kr [UCNV_DBCS] not match.\n");
         if(!testConvertToU(expected1, sizeof(expected1), 
-                sampleText1, sizeof(sampleText1)/sizeof(sampleText1[0]), "iso-2022-kr",UCNV_TO_U_CALLBACK_SUBSTITUTE ,
+                sampleText1, UPRV_LENGTHOF(sampleText1), "iso-2022-kr",UCNV_TO_U_CALLBACK_SUBSTITUTE ,
                 offsets1, TRUE))
            log_err("iso-2022-kr -> did not match.\n");
     }
                 offsets1, TRUE))
            log_err("iso-2022-kr -> did not match.\n");
     }
@@ -1709,14 +1715,14 @@ static void TestResetBehaviour(void){
                             };
 
         /*hz*/
                             };
 
         /*hz*/
-        if(!testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!testConvertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected, sizeof(expected), "HZ", UCNV_FROM_U_CALLBACK_SUBSTITUTE,NULL , TRUE))
             log_err("u->  not match.\n");
                 expected, sizeof(expected), "HZ", UCNV_FROM_U_CALLBACK_SUBSTITUTE,NULL , TRUE))
             log_err("u->  not match.\n");
-        if(!testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!testConvertFromU(sampleText, UPRV_LENGTHOF(sampleText),
                 expected, sizeof(expected), "HZ", UCNV_FROM_U_CALLBACK_SUBSTITUTE,offsets , TRUE))
             log_err("u->  not match.\n");
         if(!testConvertToU(expected1, sizeof(expected1), 
                 expected, sizeof(expected), "HZ", UCNV_FROM_U_CALLBACK_SUBSTITUTE,offsets , TRUE))
             log_err("u->  not match.\n");
         if(!testConvertToU(expected1, sizeof(expected1), 
-                sampleText1, sizeof(sampleText1)/sizeof(sampleText1[0]), "hz",UCNV_TO_U_CALLBACK_SUBSTITUTE ,
+                sampleText1, UPRV_LENGTHOF(sampleText1), "hz",UCNV_TO_U_CALLBACK_SUBSTITUTE ,
                 offsets1, TRUE))
            log_err("hz -> did not match.\n");
     }
                 offsets1, TRUE))
            log_err("hz -> did not match.\n");
     }
@@ -1735,29 +1741,29 @@ static void TestResetBehaviour(void){
 
         static const int32_t fromOffsets[] = { 0x0000, 0x0003, 0x0005, 0x0006, 0x0009, 0x0009, 0x000D }; 
         /*UTF-8*/
 
         static const int32_t fromOffsets[] = { 0x0000, 0x0003, 0x0005, 0x0006, 0x0009, 0x0009, 0x000D }; 
         /*UTF-8*/
-        if(!testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!testConvertFromU(sampleText, UPRV_LENGTHOF(sampleText),
             expected, sizeof(expected), "UTF8", UCNV_FROM_U_CALLBACK_SUBSTITUTE,offsets , TRUE))
             log_err("u-> UTF8 with offsets and flush true did not match.\n");
             expected, sizeof(expected), "UTF8", UCNV_FROM_U_CALLBACK_SUBSTITUTE,offsets , TRUE))
             log_err("u-> UTF8 with offsets and flush true did not match.\n");
-        if(!testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!testConvertFromU(sampleText, UPRV_LENGTHOF(sampleText),
             expected, sizeof(expected), "UTF8",  UCNV_FROM_U_CALLBACK_SUBSTITUTE,NULL , TRUE))
             log_err("u-> UTF8 with offsets and flush true did not match.\n");
             expected, sizeof(expected), "UTF8",  UCNV_FROM_U_CALLBACK_SUBSTITUTE,NULL , TRUE))
             log_err("u-> UTF8 with offsets and flush true did not match.\n");
-        if(!testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!testConvertFromU(sampleText, UPRV_LENGTHOF(sampleText),
             expected, sizeof(expected), "UTF8", UCNV_FROM_U_CALLBACK_SUBSTITUTE,offsets , TRUE))
             log_err("u-> UTF8 with offsets and flush true did not match.\n");
             expected, sizeof(expected), "UTF8", UCNV_FROM_U_CALLBACK_SUBSTITUTE,offsets , TRUE))
             log_err("u-> UTF8 with offsets and flush true did not match.\n");
-        if(!testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
+        if(!testConvertFromU(sampleText, UPRV_LENGTHOF(sampleText),
             expected, sizeof(expected), "UTF8",  UCNV_FROM_U_CALLBACK_SUBSTITUTE,NULL , TRUE))
             log_err("u-> UTF8 with offsets and flush true did not match.\n");
         if(!testConvertToU(expected, sizeof(expected), 
             expected, sizeof(expected), "UTF8",  UCNV_FROM_U_CALLBACK_SUBSTITUTE,NULL , TRUE))
             log_err("u-> UTF8 with offsets and flush true did not match.\n");
         if(!testConvertToU(expected, sizeof(expected), 
-            sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "UTF8",UCNV_TO_U_CALLBACK_SUBSTITUTE , NULL, TRUE))
+            sampleText, UPRV_LENGTHOF(sampleText), "UTF8",UCNV_TO_U_CALLBACK_SUBSTITUTE , NULL, TRUE))
             log_err("UTF8 -> did not match.\n");
         if(!testConvertToU(expected, sizeof(expected), 
             log_err("UTF8 -> did not match.\n");
         if(!testConvertToU(expected, sizeof(expected), 
-            sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "UTF8", UCNV_TO_U_CALLBACK_SUBSTITUTE , NULL, TRUE))
+            sampleText, UPRV_LENGTHOF(sampleText), "UTF8", UCNV_TO_U_CALLBACK_SUBSTITUTE , NULL, TRUE))
             log_err("UTF8 -> did not match.\n");
         if(!testConvertToU(expected, sizeof(expected), 
             log_err("UTF8 -> did not match.\n");
         if(!testConvertToU(expected, sizeof(expected), 
-            sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "UTF8",UCNV_TO_U_CALLBACK_SUBSTITUTE , fromOffsets, TRUE))
+            sampleText, UPRV_LENGTHOF(sampleText), "UTF8",UCNV_TO_U_CALLBACK_SUBSTITUTE , fromOffsets, TRUE))
             log_err("UTF8 -> did not match.\n");
         if(!testConvertToU(expected, sizeof(expected), 
             log_err("UTF8 -> did not match.\n");
         if(!testConvertToU(expected, sizeof(expected), 
-            sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "UTF8", UCNV_TO_U_CALLBACK_SUBSTITUTE , fromOffsets, TRUE))
+            sampleText, UPRV_LENGTHOF(sampleText), "UTF8", UCNV_TO_U_CALLBACK_SUBSTITUTE , fromOffsets, TRUE))
             log_err("UTF8 -> did not match.\n");
 
     }
             log_err("UTF8 -> did not match.\n");
 
     }
@@ -1792,7 +1798,7 @@ doTestTruncated(const char *cnvName, const uint8_t *bytes, int32_t length) {
     source=(const char *)bytes;
     sourceLimit=source+length;
     target=buffer;
     source=(const char *)bytes;
     sourceLimit=source+length;
     target=buffer;
-    targetLimit=buffer+LENGTHOF(buffer);
+    targetLimit=buffer+UPRV_LENGTHOF(buffer);
 
     /* 1. input bytes with flush=FALSE, then input nothing with flush=TRUE */
     ucnv_toUnicode(cnv, &target, targetLimit, &source, sourceLimit, NULL, FALSE, &errorCode);
 
     /* 1. input bytes with flush=FALSE, then input nothing with flush=TRUE */
     ucnv_toUnicode(cnv, &target, targetLimit, &source, sourceLimit, NULL, FALSE, &errorCode);
@@ -1866,7 +1872,7 @@ TestTruncated() {
     };
     int32_t i;
 
     };
     int32_t i;
 
-    for(i=0; i<LENGTHOF(testCases); ++i) {
+    for(i=0; i<UPRV_LENGTHOF(testCases); ++i) {
         doTestTruncated(testCases[i].cnvName, testCases[i].bytes, testCases[i].length);
     }
 }
         doTestTruncated(testCases[i].cnvName, testCases[i].bytes, testCases[i].length);
     }
 }
@@ -1901,9 +1907,8 @@ TestUnicodeSet() {
 #endif
         "IMAP-mailbox-name"
     };
 #endif
         "IMAP-mailbox-name"
     };
-
-    static const char *const lmbcsNames[]={
 #if !UCONFIG_NO_LEGACY_CONVERSION
 #if !UCONFIG_NO_LEGACY_CONVERSION
+    static const char *const lmbcsNames[]={
         "LMBCS-1",
         "LMBCS-2",
         "LMBCS-3",
         "LMBCS-1",
         "LMBCS-2",
         "LMBCS-3",
@@ -1916,8 +1921,8 @@ TestUnicodeSet() {
         "LMBCS-17",
         "LMBCS-18",
         "LMBCS-19"
         "LMBCS-17",
         "LMBCS-18",
         "LMBCS-19"
-#endif
     };
     };
+#endif
 
     static const NameRange nameRanges[]={
         { "US-ASCII", 0, 0x7f, -1, -1, 0x80, 0x10ffff },
 
     static const NameRange nameRanges[]={
         { "US-ASCII", 0, 0x7f, -1, -1, 0x80, 0x10ffff },
@@ -1928,7 +1933,7 @@ TestUnicodeSet() {
 #if !UCONFIG_NO_LEGACY_CONVERSION
         { "UTF-8", 0, 0xd7ff, 0xe000, 0x10ffff, 0xd800, 0xdfff },
         { "windows-1251", 0, 0x7f, 0x410, 0x44f, 0x3000, 0xd7ff },
 #if !UCONFIG_NO_LEGACY_CONVERSION
         { "UTF-8", 0, 0xd7ff, 0xe000, 0x10ffff, 0xd800, 0xdfff },
         { "windows-1251", 0, 0x7f, 0x410, 0x44f, 0x3000, 0xd7ff },
-        { "HZ", 0x410, 0x44f, 0x4e00, 0x4eff, 0xac00, 0xd7ff },
+        /* HZ test case fixed and moved to intltest's conversion.txt, ticket #6002 */
         { "shift-jis", 0x3041, 0x3093, 0x30a1, 0x30f3, 0x900, 0x1cff }
 #else
         { "UTF-8", 0, 0xd7ff, 0xe000, 0x10ffff, 0xd800, 0xdfff }
         { "shift-jis", 0x3041, 0x3093, 0x30a1, 0x30f3, 0x900, 0x1cff }
 #else
         { "UTF-8", 0, 0xd7ff, 0xe000, 0x10ffff, 0xd800, 0xdfff }
@@ -1944,7 +1949,7 @@ TestUnicodeSet() {
         name=ucnv_getAvailableName(i);
         cnv=ucnv_open(name, &errorCode);
         if(U_FAILURE(errorCode)) {
         name=ucnv_getAvailableName(i);
         cnv=ucnv_open(name, &errorCode);
         if(U_FAILURE(errorCode)) {
-            log_err("error: unable to open converter %s - %s\n",
+            log_data_err("error: unable to open converter %s - %s\n",
                     name, u_errorName(errorCode));
             continue;
         }
                     name, u_errorName(errorCode));
             continue;
         }
@@ -1962,12 +1967,12 @@ TestUnicodeSet() {
     }
 
     /* test converters that are known to convert all of Unicode (except maybe for surrogates) */
     }
 
     /* test converters that are known to convert all of Unicode (except maybe for surrogates) */
-    for(i=0; i<LENGTHOF(completeSetNames); ++i) {
+    for(i=0; i<UPRV_LENGTHOF(completeSetNames); ++i) {
         errorCode=U_ZERO_ERROR;
         name=completeSetNames[i];
         cnv=ucnv_open(name, &errorCode);
         if(U_FAILURE(errorCode)) {
         errorCode=U_ZERO_ERROR;
         name=completeSetNames[i];
         cnv=ucnv_open(name, &errorCode);
         if(U_FAILURE(errorCode)) {
-            log_err("error: unable to open converter %s - %s\n",
+            log_data_err("error: unable to open converter %s - %s\n",
                     name, u_errorName(errorCode));
             continue;
         }
                     name, u_errorName(errorCode));
             continue;
         }
@@ -1984,13 +1989,14 @@ TestUnicodeSet() {
         ucnv_close(cnv);
     }
 
         ucnv_close(cnv);
     }
 
+#if !UCONFIG_NO_LEGACY_CONVERSION
     /* test LMBCS variants which convert all of Unicode except for U+F6xx */
     /* test LMBCS variants which convert all of Unicode except for U+F6xx */
-    for(i=0; i<LENGTHOF(lmbcsNames); ++i) {
+    for(i=0; i<UPRV_LENGTHOF(lmbcsNames); ++i) {
         errorCode=U_ZERO_ERROR;
         name=lmbcsNames[i];
         cnv=ucnv_open(name, &errorCode);
         if(U_FAILURE(errorCode)) {
         errorCode=U_ZERO_ERROR;
         name=lmbcsNames[i];
         cnv=ucnv_open(name, &errorCode);
         if(U_FAILURE(errorCode)) {
-            log_err("error: unable to open converter %s - %s\n",
+            log_data_err("error: unable to open converter %s - %s\n",
                     name, u_errorName(errorCode));
             continue;
         }
                     name, u_errorName(errorCode));
             continue;
         }
@@ -2006,9 +2012,10 @@ TestUnicodeSet() {
 
         ucnv_close(cnv);
     }
 
         ucnv_close(cnv);
     }
+#endif
 
     /* test specific sets */
 
     /* test specific sets */
-    for(i=0; i<LENGTHOF(nameRanges); ++i) {
+    for(i=0; i<UPRV_LENGTHOF(nameRanges); ++i) {
         errorCode=U_ZERO_ERROR;
         name=nameRanges[i].name;
         cnv=ucnv_open(name, &errorCode);
         errorCode=U_ZERO_ERROR;
         name=nameRanges[i].name;
         cnv=ucnv_open(name, &errorCode);