+ u_strToUTF8(utf8Target, 256, &utf8TargetLen, target, tLen, &status);
+ if(U_SUCCESS(status)) {
+ {
+ /* ucol_strcollUTF8 */
+ compareResulta = ucol_strcollUTF8(myCollation, utf8Source, utf8SourceLen, utf8Target, utf8TargetLen, &status);
+ if (U_FAILURE(status)) {
+ log_err("Error in ucol_strcollUTF8 with explicit length\n");
+ status = U_ZERO_ERROR;
+ } else if (compareResulta != result) {
+ log_err("ucol_strcollUTF8 with explicit length returned wrong result (%i exp. %i): %s, %s\n",
+ compareResulta, result, aescstrdup(source,-1), aescstrdup(target,-1));
+ }
+ compareResulta = ucol_strcollUTF8(myCollation, utf8Source, -1, utf8Target, -1, &status);
+ if (U_FAILURE(status)) {
+ log_err("Error in ucol_strcollUTF8 with null terminated strings\n");
+ status = U_ZERO_ERROR;
+ } else if (compareResulta != result) {
+ log_err("ucol_strcollUTF8 with null terminated strings returned wrong result (%i exp. %i): %s, %s\n",
+ compareResulta, result, aescstrdup(source,-1), aescstrdup(target,-1));
+ }
+ }
+
+ {
+ /* char iterator over UTF8 */
+ UCollationResult compareResultUTF8Iter = result, compareResultUTF8IterNorm = result;
+
+ uiter_setUTF8(&sIter, utf8Source, utf8SourceLen);
+ uiter_setUTF8(&tIter, utf8Target, utf8TargetLen);
+ compareResultUTF8Iter = ucol_strcollIter(myCollation, &sIter, &tIter, &status);
+
+ ucol_setAttribute(myCollation, UCOL_NORMALIZATION_MODE, UCOL_ON, &status);
+ sIter.move(&sIter, 0, UITER_START);
+ tIter.move(&tIter, 0, UITER_START);
+ compareResultUTF8IterNorm = ucol_strcollIter(myCollation, &sIter, &tIter, &status);
+
+ ucol_setAttribute(myCollation, UCOL_NORMALIZATION_MODE, norm, &status);
+ if(compareResultUTF8Iter != compareResultIter) {
+ log_err("different results in iterative comparison for UTF-16 and UTF-8 encoded strings. %s, %s\n", aescstrdup(source,-1), aescstrdup(target,-1));
+ }
+ if(compareResultUTF8Iter != compareResultUTF8IterNorm) {
+ log_err("different results in iterative when normalization is turned on with UTF-8 strings. %s, %s\n", aescstrdup(source,-1), aescstrdup(target,-1));
+ }
+ }
+ } else {
+ log_verbose("Target UTF-8 buffer too small! Did not compare!\n");
+ }
+ if(U_FAILURE(status)) {
+ log_verbose("UTF-8 strcoll failed! Ignoring result\n");
+ }