2 *******************************************************************************
4 * Copyright (C) 2003-2013, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 *******************************************************************************
8 * file name: idnatest.c
10 * tab size: 8 (not used)
13 * created on: 2003jul11
14 * created by: Ram Viswanadha
18 #include "unicode/utypes.h"
22 #include "unicode/ustring.h"
23 #include "unicode/uidna.h"
28 #define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
29 #define MAX_DEST_SIZE 1000
31 static void TestToUnicode(void);
32 static void TestToASCII(void);
33 static void TestIDNToUnicode(void);
34 static void TestIDNToASCII(void);
35 static void TestCompare(void);
36 static void TestJB4490(void);
37 static void TestJB4475(void);
38 static void TestLength(void);
39 static void TestJB5273(void);
40 static void TestUTS46(void);
42 void addIDNATest(TestNode** root);
46 (U_EXPORT2 *TestFunc) ( const UChar *src, int32_t srcLength,
47 UChar *dest, int32_t destCapacity,
48 int32_t options, UParseError *parseError,
51 (U_EXPORT2 *CompareFunc) (const UChar *s1, int32_t s1Len,
52 const UChar *s2, int32_t s2Len,
58 addIDNATest(TestNode** root)
60 addTest(root, &TestToUnicode, "idna/TestToUnicode");
61 addTest(root, &TestToASCII, "idna/TestToASCII");
62 addTest(root, &TestIDNToUnicode, "idna/TestIDNToUnicode");
63 addTest(root, &TestIDNToASCII, "idna/TestIDNToASCII");
64 addTest(root, &TestCompare, "idna/TestCompare");
65 addTest(root, &TestJB4490, "idna/TestJB4490");
66 addTest(root, &TestJB4475, "idna/TestJB4475");
67 addTest(root, &TestLength, "idna/TestLength");
68 addTest(root, &TestJB5273, "idna/TestJB5273");
69 addTest(root, &TestUTS46, "idna/TestUTS46");
73 testAPI(const UChar* src, const UChar* expected, const char* testName,
74 UBool useSTD3ASCIIRules,UErrorCode expectedStatus,
75 UBool doCompare, UBool testUnassigned, TestFunc func){
77 UErrorCode status = U_ZERO_ERROR;
78 UChar destStack[MAX_DEST_SIZE];
81 int32_t expectedLen = (expected != NULL) ? u_strlen(expected) : 0;
82 int32_t options = (useSTD3ASCIIRules == TRUE) ? UIDNA_USE_STD3_RULES : UIDNA_DEFAULT;
83 UParseError parseError;
88 tSrcLen = u_strlen(src);
89 tSrc =(UChar*) malloc( U_SIZEOF_UCHAR * tSrcLen );
90 memcpy(tSrc,src,tSrcLen * U_SIZEOF_UCHAR);
93 /* test null-terminated source and return value of number of UChars required */
95 destLen = func(src,-1,NULL,0,options, &parseError , &status);
96 if(status == U_BUFFER_OVERFLOW_ERROR){
97 status = U_ZERO_ERROR; /* reset error code */
98 if(destLen+1 < MAX_DEST_SIZE){
100 destLen = func(src,-1,dest,destLen+1,options, &parseError, &status);
101 /* TODO : compare output with expected */
102 if(U_SUCCESS(status) && expectedStatus != U_IDNA_STD3_ASCII_RULES_ERROR&& (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
103 log_err("Did not get the expected result for null terminated source.\n" );
106 log_err( "%s null terminated source failed. Requires destCapacity > 300\n",testName);
110 if(status != expectedStatus){
111 log_err_status(status, "Did not get the expected error for %s null terminated source failed. Expected: %s Got: %s\n",testName, u_errorName(expectedStatus), u_errorName(status));
116 status = U_ZERO_ERROR;
117 destLen = func(src,-1,NULL,0,options | UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
118 if(status == U_BUFFER_OVERFLOW_ERROR){
119 status = U_ZERO_ERROR; /* reset error code */
120 if(destLen+1 < MAX_DEST_SIZE){
122 destLen = func(src,-1,dest,destLen+1,options | UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
123 /* TODO : compare output with expected */
124 if(U_SUCCESS(status) && (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
125 log_err("Did not get the expected result for %s null terminated source with both options set.\n",testName);
129 log_err( "%s null terminated source failed. Requires destCapacity > 300\n",testName);
132 /*testing query string*/
133 if(status != expectedStatus && expectedStatus != U_IDNA_UNASSIGNED_ERROR){
134 log_err( "Did not get the expected error for %s null terminated source with options set. Expected: %s Got: %s\n",testName, u_errorName(expectedStatus), u_errorName(status));
138 status = U_ZERO_ERROR;
140 /* test source with lengthand return value of number of UChars required*/
141 destLen = func(tSrc, tSrcLen, NULL,0,options, &parseError, &status);
142 if(status == U_BUFFER_OVERFLOW_ERROR){
143 status = U_ZERO_ERROR; /* reset error code */
144 if(destLen+1 < MAX_DEST_SIZE){
146 destLen = func(src,u_strlen(src),dest,destLen+1,options, &parseError, &status);
147 /* TODO : compare output with expected */
148 if(U_SUCCESS(status) && (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
149 log_err("Did not get the expected result for %s with source length.\n",testName);
152 log_err( "%s with source length failed. Requires destCapacity > 300\n",testName);
156 if(status != expectedStatus){
157 log_err( "Did not get the expected error for %s with source length. Expected: %s Got: %s\n",testName, u_errorName(expectedStatus), u_errorName(status));
160 status = U_ZERO_ERROR;
162 destLen = func(tSrc,tSrcLen,NULL,0,options | UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
164 if(status == U_BUFFER_OVERFLOW_ERROR){
165 status = U_ZERO_ERROR; /* reset error code */
166 if(destLen+1 < MAX_DEST_SIZE){
168 destLen = func(src,u_strlen(src),dest,destLen+1,options | UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
169 /* TODO : compare output with expected */
170 if(U_SUCCESS(status) && (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
171 log_err("Did not get the expected result for %s with source length and both options set.\n",testName);
174 log_err( "%s with source length failed. Requires destCapacity > 300\n",testName);
177 /*testing query string*/
178 if(status != expectedStatus && expectedStatus != U_IDNA_UNASSIGNED_ERROR){
179 log_err( "Did not get the expected error for %s with source length and options set. Expected: %s Got: %s\n",testName, u_errorName(expectedStatus), u_errorName(status));
183 status = U_ZERO_ERROR;
184 destLen = func(src,-1,NULL,0,options | UIDNA_USE_STD3_RULES, &parseError, &status);
185 if(status == U_BUFFER_OVERFLOW_ERROR){
186 status = U_ZERO_ERROR; /* reset error code*/
187 if(destLen+1 < MAX_DEST_SIZE){
189 destLen = func(src,-1,dest,destLen+1,options | UIDNA_USE_STD3_RULES, &parseError, &status);
190 /* TODO : compare output with expected*/
191 if(U_SUCCESS(status) && (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
192 log_err("Did not get the expected result for %s null terminated source with both options set.\n",testName);
196 log_err( "%s null terminated source failed. Requires destCapacity > 300\n",testName);
199 /*testing query string*/
200 if(status != expectedStatus){
201 log_err( "Did not get the expected error for %s null terminated source with options set. Expected: %s Got: %s\n",testName, u_errorName(expectedStatus), u_errorName(status));
204 status = U_ZERO_ERROR;
206 destLen = func(tSrc,tSrcLen,NULL,0,options | UIDNA_USE_STD3_RULES, &parseError, &status);
208 if(status == U_BUFFER_OVERFLOW_ERROR){
209 status = U_ZERO_ERROR; /* reset error code*/
210 if(destLen+1 < MAX_DEST_SIZE){
212 destLen = func(src,u_strlen(src),dest,destLen+1,options | UIDNA_USE_STD3_RULES, &parseError, &status);
213 /* TODO : compare output with expected*/
214 if(U_SUCCESS(status) && (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
215 log_err("Did not get the expected result for %s with source length and both options set.\n",testName);
218 log_err( "%s with source length failed. Requires destCapacity > 300\n",testName);
221 /*testing query string*/
222 if(status != expectedStatus && expectedStatus != U_IDNA_UNASSIGNED_ERROR){
223 log_err( "Did not get the expected error for %s with source length and options set. Expected: %s Got: %s\n",testName, u_errorName(expectedStatus), u_errorName(status));
228 static const UChar unicodeIn[][41] ={
230 0x0644, 0x064A, 0x0647, 0x0645, 0x0627, 0x0628, 0x062A, 0x0643, 0x0644,
231 0x0645, 0x0648, 0x0634, 0x0639, 0x0631, 0x0628, 0x064A, 0x061F, 0x0000
234 0x4ED6, 0x4EEC, 0x4E3A, 0x4EC0, 0x4E48, 0x4E0D, 0x8BF4, 0x4E2D, 0x6587,
238 0x0050, 0x0072, 0x006F, 0x010D, 0x0070, 0x0072, 0x006F, 0x0073, 0x0074,
239 0x011B, 0x006E, 0x0065, 0x006D, 0x006C, 0x0075, 0x0076, 0x00ED, 0x010D,
240 0x0065, 0x0073, 0x006B, 0x0079, 0x0000
243 0x05DC, 0x05DE, 0x05D4, 0x05D4, 0x05DD, 0x05E4, 0x05E9, 0x05D5, 0x05D8,
244 0x05DC, 0x05D0, 0x05DE, 0x05D3, 0x05D1, 0x05E8, 0x05D9, 0x05DD, 0x05E2,
245 0x05D1, 0x05E8, 0x05D9, 0x05EA, 0x0000
248 0x092F, 0x0939, 0x0932, 0x094B, 0x0917, 0x0939, 0x093F, 0x0928, 0x094D,
249 0x0926, 0x0940, 0x0915, 0x094D, 0x092F, 0x094B, 0x0902, 0x0928, 0x0939,
250 0x0940, 0x0902, 0x092C, 0x094B, 0x0932, 0x0938, 0x0915, 0x0924, 0x0947,
251 0x0939, 0x0948, 0x0902, 0x0000
254 0x306A, 0x305C, 0x307F, 0x3093, 0x306A, 0x65E5, 0x672C, 0x8A9E, 0x3092,
255 0x8A71, 0x3057, 0x3066, 0x304F, 0x308C, 0x306A, 0x3044, 0x306E, 0x304B,
260 0xC138, 0xACC4, 0xC758, 0xBAA8, 0xB4E0, 0xC0AC, 0xB78C, 0xB4E4, 0xC774,
261 0xD55C, 0xAD6D, 0xC5B4, 0xB97C, 0xC774, 0xD574, 0xD55C, 0xB2E4, 0xBA74,
262 0xC5BC, 0xB9C8, 0xB098, 0xC88B, 0xC744, 0xAE4C, 0x0000
266 0x043F, 0x043E, 0x0447, 0x0435, 0x043C, 0x0443, 0x0436, 0x0435, 0x043E,
267 0x043D, 0x0438, 0x043D, 0x0435, 0x0433, 0x043E, 0x0432, 0x043E, 0x0440,
268 0x044F, 0x0442, 0x043F, 0x043E, 0x0440, 0x0443, 0x0441, 0x0441, 0x043A,
272 0x0050, 0x006F, 0x0072, 0x0071, 0x0075, 0x00E9, 0x006E, 0x006F, 0x0070,
273 0x0075, 0x0065, 0x0064, 0x0065, 0x006E, 0x0073, 0x0069, 0x006D, 0x0070,
274 0x006C, 0x0065, 0x006D, 0x0065, 0x006E, 0x0074, 0x0065, 0x0068, 0x0061,
275 0x0062, 0x006C, 0x0061, 0x0072, 0x0065, 0x006E, 0x0045, 0x0073, 0x0070,
276 0x0061, 0x00F1, 0x006F, 0x006C, 0x0000
279 0x4ED6, 0x5011, 0x7232, 0x4EC0, 0x9EBD, 0x4E0D, 0x8AAA, 0x4E2D, 0x6587,
283 0x0054, 0x1EA1, 0x0069, 0x0073, 0x0061, 0x006F, 0x0068, 0x1ECD, 0x006B,
284 0x0068, 0x00F4, 0x006E, 0x0067, 0x0074, 0x0068, 0x1EC3, 0x0063, 0x0068,
285 0x1EC9, 0x006E, 0x00F3, 0x0069, 0x0074, 0x0069, 0x1EBF, 0x006E, 0x0067,
286 0x0056, 0x0069, 0x1EC7, 0x0074, 0x0000
289 0x0033, 0x5E74, 0x0042, 0x7D44, 0x91D1, 0x516B, 0x5148, 0x751F, 0x0000
292 0x5B89, 0x5BA4, 0x5948, 0x7F8E, 0x6075, 0x002D, 0x0077, 0x0069, 0x0074,
293 0x0068, 0x002D, 0x0053, 0x0055, 0x0050, 0x0045, 0x0052, 0x002D, 0x004D,
294 0x004F, 0x004E, 0x004B, 0x0045, 0x0059, 0x0053, 0x0000
297 0x0048, 0x0065, 0x006C, 0x006C, 0x006F, 0x002D, 0x0041, 0x006E, 0x006F,
298 0x0074, 0x0068, 0x0065, 0x0072, 0x002D, 0x0057, 0x0061, 0x0079, 0x002D,
299 0x305D, 0x308C, 0x305E, 0x308C, 0x306E, 0x5834, 0x6240, 0x0000
302 0x3072, 0x3068, 0x3064, 0x5C4B, 0x6839, 0x306E, 0x4E0B, 0x0032, 0x0000
305 0x004D, 0x0061, 0x006A, 0x0069, 0x3067, 0x004B, 0x006F, 0x0069, 0x3059,
306 0x308B, 0x0035, 0x79D2, 0x524D, 0x0000
309 0x30D1, 0x30D5, 0x30A3, 0x30FC, 0x0064, 0x0065, 0x30EB, 0x30F3, 0x30D0,
313 0x305D, 0x306E, 0x30B9, 0x30D4, 0x30FC, 0x30C9, 0x3067, 0x0000
315 /* test non-BMP code points */
317 0xD800, 0xDF00, 0xD800, 0xDF01, 0xD800, 0xDF02, 0xD800, 0xDF03, 0xD800, 0xDF05,
318 0xD800, 0xDF06, 0xD800, 0xDF07, 0xD800, 0xDF09, 0xD800, 0xDF0A, 0xD800, 0xDF0B,
322 0xD800, 0xDF0D, 0xD800, 0xDF0C, 0xD800, 0xDF1E, 0xD800, 0xDF0F, 0xD800, 0xDF16,
323 0xD800, 0xDF15, 0xD800, 0xDF14, 0xD800, 0xDF12, 0xD800, 0xDF10, 0xD800, 0xDF20,
329 0x03b5, 0x03bb, 0x03bb, 0x03b7, 0x03bd, 0x03b9, 0x03ba, 0x03ac
333 0x0062, 0x006f, 0x006e, 0x0121, 0x0075, 0x0073, 0x0061, 0x0127,
338 0x043f, 0x043e, 0x0447, 0x0435, 0x043c, 0x0443, 0x0436, 0x0435,
339 0x043e, 0x043d, 0x0438, 0x043d, 0x0435, 0x0433, 0x043e, 0x0432,
340 0x043e, 0x0440, 0x044f, 0x0442, 0x043f, 0x043e, 0x0440, 0x0443,
341 0x0441, 0x0441, 0x043a, 0x0438
344 0x0054,0x0045,0x0053,0x0054
348 static const char * const asciiIn[] = {
349 "xn--egbpdaj6bu4bxfgehfvwxn",
350 "xn--ihqwcrb4cv8a8dqg056pqjye",
351 "xn--Proprostnemluvesky-uyb24dma41a",
352 "xn--4dbcagdahymbxekheh6e0a7fei0b",
353 "xn--i1baa7eci9glrd9b2ae1bj0hfcgg6iyaf8o0a1dig0cd",
354 "xn--n8jok5ay5dzabd5bym9f0cm5685rrjetr6pdxa",
355 /* "xn--989aomsvi5e83db1d2a355cv1e0vak1dwrv93d5xbh15a0dt30a5jpsd879ccm6fea98c",*/
356 "xn--b1abfaaepdrnnbgefbaDotcwatmq2g4l",
357 "xn--PorqunopuedensimplementehablarenEspaol-fmd56a",
358 "xn--ihqwctvzc91f659drss3x8bo0yb",
359 "xn--TisaohkhngthchnitingVit-kjcr8268qyxafd2f1b9g",
360 "xn--3B-ww4c5e180e575a65lsy2b",
361 "xn---with-SUPER-MONKEYS-pc58ag80a8qai00g7n9n",
362 "xn--Hello-Another-Way--fc4qua05auwb3674vfr0b",
363 "xn--2-u9tlzr9756bt3uc0v",
364 "xn--MajiKoi5-783gue6qz075azm5e",
365 "xn--de-jg4avhby1noc0d",
366 "xn--d9juau41awczczp",
368 "XN--db8CBHEJLGH4E0AL",
369 "xn--hxargifdar", /* Greek */
370 "xn--bonusaa-5bb1da", /* Maltese */
371 "xn--b1abfaaepdrnnbgefbadotcwatmq2g4l", /* Russian (Cyrillic)*/
376 static const char * const domainNames[] = {
377 "slip129-37-118-146.nc.us.ibm.net",
378 "saratoga.pe.utexas.edu",
379 "dial-120-45.ots.utexas.edu",
380 "woo-085.dorms.waller.net",
381 "hd30-049.hil.compuserve.com",
382 "pem203-31.pe.ttu.edu",
383 "56K-227.MaxTNT3.pdq.net",
384 "dial-36-2.ots.utexas.edu",
385 "slip129-37-23-152.ga.us.ibm.net",
386 "ts45ip119.cadvision.com",
387 "sdn-ts-004txaustP05.dialsprint.net",
388 "bar-tnt1s66.erols.com",
389 "101.st-louis-15.mo.dial-access.att.net",
391 "dial-13-2.ots.utexas.edu",
392 "net-redynet29.datamarkets.com.ar",
393 "ccs-shiva28.reacciun.net.ve",
394 "7.houston-11.tx.dial-access.att.net",
395 "ingw129-37-120-26.mo.us.ibm.net",
396 "dialup6.austintx.com",
398 "slip129-37-119-194.nc.us.ibm.net",
399 "cs7.dillons.co.uk.203.119.193.in-addr.arpa",
400 "swprd1.innovplace.saskatoon.sk.ca",
401 "bikini.bologna.maraut.it",
402 "node91.subnet159-198-79.baxter.com",
403 "cust19.max5.new-york.ny.ms.uu.net",
404 "balexander.slip.andrew.cmu.edu",
405 "pool029.max2.denver.co.dynip.alter.net",
406 "cust49.max9.new-york.ny.ms.uu.net",
407 "s61.abq-dialin2.hollyberry.com",
408 "\\u0917\\u0928\\u0947\\u0936.sanjose.ibm.com", /*':'(0x003a) produces U_IDNA_STD3_ASCII_RULES_ERROR*/
410 /* "www.\\u00E0\\u00B3\\u00AF.com",//' ' (0x0020) produces U_IDNA_STD3_ASCII_RULES_ERROR*/
411 "www.\\u00C2\\u00A4.com",
412 "www.\\u00C2\\u00A3.com",
413 /* "\\u0025", //'%' (0x0025) produces U_IDNA_STD3_ASCII_RULES_ERROR*/
414 /* "\\u005C\\u005C", //'\' (0x005C) produces U_IDNA_STD3_ASCII_RULES_ERROR*/
417 /*"www.\\u0021.com",*/
418 /*"www.\\u0024.com",*/
420 /* These yeild U_IDNA_PROHIBITED_ERROR*/
421 /*"\\u00CF\\u0082.com",*/
422 /*"\\u00CE\\u00B2\\u00C3\\u009Fss.com",*/
423 /*"\\u00E2\\u0098\\u00BA.com",*/
432 UChar buf[MAX_DEST_SIZE];
433 const char* testName = "uidna_toASCII";
434 TestFunc func = uidna_toASCII;
435 for(i=0;i< (int32_t)(sizeof(unicodeIn)/sizeof(unicodeIn[0])); i++){
436 u_charsToUChars(asciiIn[i],buf, (int32_t)strlen(asciiIn[i])+1);
437 testAPI(unicodeIn[i], buf,testName, FALSE,U_ZERO_ERROR, TRUE, TRUE, func);
446 UChar buf[MAX_DEST_SIZE];
447 const char* testName = "uidna_toUnicode";
448 TestFunc func = uidna_toUnicode;
449 for(i=0;i< (int32_t)(sizeof(asciiIn)/sizeof(asciiIn[0])); i++){
450 u_charsToUChars(asciiIn[i],buf, (int32_t)strlen(asciiIn[i])+1);
451 testAPI(buf,unicodeIn[i],testName,FALSE,U_ZERO_ERROR, TRUE, TRUE, func);
459 UChar buf[MAX_DEST_SIZE];
460 UChar expected[MAX_DEST_SIZE];
461 UErrorCode status = U_ZERO_ERROR;
463 UParseError parseError;
464 const char* testName="uidna_IDNToUnicode";
465 TestFunc func = uidna_IDNToUnicode;
466 for(i=0;i< (int32_t)(sizeof(domainNames)/sizeof(domainNames[0])); i++){
467 bufLen = (int32_t)strlen(domainNames[i]);
468 bufLen = u_unescape(domainNames[i],buf, bufLen+1);
469 func(buf,bufLen,expected,MAX_DEST_SIZE, UIDNA_ALLOW_UNASSIGNED, &parseError,&status);
470 if(U_FAILURE(status)){
471 log_err_status(status, "%s failed to convert domainNames[%i].Error: %s \n",testName, i, u_errorName(status));
474 testAPI(buf,expected,testName,FALSE,U_ZERO_ERROR, TRUE, TRUE, func);
475 /*test toUnicode with all labels in the string*/
476 testAPI(buf,expected,testName, FALSE,U_ZERO_ERROR, TRUE, TRUE, func);
477 if(U_FAILURE(status)){
478 log_err( "%s failed to convert domainNames[%i].Error: %s \n",testName,i, u_errorName(status));
488 UChar buf[MAX_DEST_SIZE];
489 UChar expected[MAX_DEST_SIZE];
490 UErrorCode status = U_ZERO_ERROR;
492 UParseError parseError;
493 const char* testName="udina_IDNToASCII";
494 TestFunc func=uidna_IDNToASCII;
496 for(i=0;i< (int32_t)(sizeof(domainNames)/sizeof(domainNames[0])); i++){
497 bufLen = (int32_t)strlen(domainNames[i]);
498 bufLen = u_unescape(domainNames[i],buf, bufLen+1);
499 func(buf,bufLen,expected,MAX_DEST_SIZE, UIDNA_ALLOW_UNASSIGNED, &parseError,&status);
500 if(U_FAILURE(status)){
501 log_err_status(status, "%s failed to convert domainNames[%i].Error: %s \n",testName,i, u_errorName(status));
504 testAPI(buf,expected,testName, FALSE,U_ZERO_ERROR, TRUE, TRUE, func);
505 /*test toASCII with all labels in the string*/
506 testAPI(buf,expected,testName, FALSE,U_ZERO_ERROR, FALSE, TRUE, func);
507 if(U_FAILURE(status)){
508 log_err( "%s failed to convert domainNames[%i].Error: %s \n",testName,i, u_errorName(status));
518 testCompareWithSrc(const UChar* s1, int32_t s1Len,
519 const UChar* s2, int32_t s2Len,
520 const char* testName, CompareFunc func,
523 UErrorCode status = U_ZERO_ERROR;
524 int32_t retVal = func(s1,-1,s2,-1,UIDNA_DEFAULT,&status);
526 if(isEqual==TRUE && retVal !=0){
527 log_err("Did not get the expected result for %s with null termniated strings.\n",testName);
529 if(U_FAILURE(status)){
530 log_err_status(status, "%s null terminated source failed. Error: %s\n", testName,u_errorName(status));
533 status = U_ZERO_ERROR;
534 retVal = func(s1,-1,s2,-1,UIDNA_ALLOW_UNASSIGNED,&status);
536 if(isEqual==TRUE && retVal !=0){
537 log_err("Did not get the expected result for %s with null termniated strings with options set.\n", testName);
539 if(U_FAILURE(status)){
540 log_err_status(status, "%s null terminated source and options set failed. Error: %s\n",testName, u_errorName(status));
543 status = U_ZERO_ERROR;
544 retVal = func(s1,s1Len,s2,s2Len,UIDNA_DEFAULT,&status);
546 if(isEqual==TRUE && retVal !=0){
547 log_err("Did not get the expected result for %s with string length.\n",testName);
549 if(U_FAILURE(status)){
550 log_err_status(status, "%s with string length. Error: %s\n",testName, u_errorName(status));
553 status = U_ZERO_ERROR;
554 retVal = func(s1,s1Len,s2,s2Len,UIDNA_ALLOW_UNASSIGNED,&status);
556 if(isEqual==TRUE && retVal !=0){
557 log_err("Did not get the expected result for %s with string length and options set.\n",testName);
559 if(U_FAILURE(status)){
560 log_err_status(status, "%s with string length and options set. Error: %s\n", u_errorName(status), testName);
569 const char* testName ="uidna_compare";
570 CompareFunc func = uidna_compare;
572 UChar www[] = {0x0057, 0x0057, 0x0057, 0x002E, 0x0000};
573 UChar com[] = {0x002E, 0x0043, 0x004F, 0x004D, 0x0000};
574 UChar buf[MAX_DEST_SIZE]={0x0057, 0x0057, 0x0057, 0x002E, 0x0000};
575 UChar source[MAX_DEST_SIZE]={0},
576 uni0[MAX_DEST_SIZE]={0},
577 uni1[MAX_DEST_SIZE]={0},
578 ascii0[MAX_DEST_SIZE]={0},
579 ascii1[MAX_DEST_SIZE]={0},
580 temp[MAX_DEST_SIZE] ={0};
583 u_strcat(uni0,unicodeIn[0]);
586 u_strcat(uni1,unicodeIn[1]);
589 u_charsToUChars(asciiIn[0], temp, (int32_t)strlen(asciiIn[0]));
590 u_strcat(ascii0,temp);
591 u_strcat(ascii0,com);
593 memset(temp, 0, U_SIZEOF_UCHAR * MAX_DEST_SIZE);
595 u_charsToUChars(asciiIn[1], temp, (int32_t)strlen(asciiIn[1]));
596 u_strcat(ascii1,temp);
597 u_strcat(ascii1,com);
600 u_strcat(source, www);
602 for(i=0;i< (int32_t)(sizeof(unicodeIn)/sizeof(unicodeIn[0])); i++){
606 memset(buf+4, 0, (MAX_DEST_SIZE-4) * U_SIZEOF_UCHAR);
608 u_charsToUChars(asciiIn[i],buf+4, (int32_t)strlen(asciiIn[i]));
612 /* for every entry in unicodeIn array
613 prepend www. and append .com*/
615 u_strncat(source,unicodeIn[i], u_strlen(unicodeIn[i]));
616 u_strcat(source,com);
618 /* a) compare it with itself*/
620 srcLen = u_strlen(src);
622 testCompareWithSrc(src,srcLen,src,srcLen,testName, func, TRUE);
624 /* b) compare it with asciiIn equivalent */
625 testCompareWithSrc(src,srcLen,buf,u_strlen(buf),testName, func,TRUE);
627 /* c) compare it with unicodeIn not equivalent*/
629 testCompareWithSrc(src,srcLen,uni1,u_strlen(uni1),testName, func,FALSE);
631 testCompareWithSrc(src,srcLen,uni0,u_strlen(uni0),testName, func,FALSE);
633 /* d) compare it with asciiIn not equivalent */
635 testCompareWithSrc(src,srcLen,ascii1,u_strlen(ascii1),testName, func,FALSE);
637 testCompareWithSrc(src,srcLen,ascii0,u_strlen(ascii0),testName, func,FALSE);
643 static void TestJB4490(){
644 static const UChar data[][50]= {
645 {0x00F5,0x00dE,0x00dF,0x00dD, 0x0000},
648 UChar output1[40] = {0};
649 UChar output2[40] = {0};
651 for(i=0; i< sizeof(data)/sizeof(data[0]); i++){
652 const UChar* src1 = data[i];
653 int32_t src1Len = u_strlen(src1);
654 UChar* dest1 = output1;
655 int32_t dest1Len = 40;
656 UErrorCode status = U_ZERO_ERROR;
660 UChar* dest2 = output2;
661 int32_t dest2Len = 40;
662 dest1Len = uidna_toASCII(src1, src1Len, dest1, dest1Len,UIDNA_DEFAULT, &ps, &status);
663 if(U_FAILURE(status)){
664 log_err_status(status, "uidna_toUnicode failed with error %s.\n", u_errorName(status));
668 dest2Len = uidna_toUnicode(src2, src2Len, dest2, dest2Len, UIDNA_DEFAULT, &ps, &status);
669 if(U_FAILURE(status)){
670 log_err_status(status, "uidna_toUnicode failed with error %s.\n", u_errorName(status));
675 static void TestJB4475(){
677 static const UChar input[][10] = {
678 {0x0054,0x0045,0x0053,0x0054,0x0000},/* TEST */
679 {0x0074,0x0065,0x0073,0x0074,0x0000} /* test */
682 UChar output[40] = {0};
683 for(i=0; i< sizeof(input)/sizeof(input[0]); i++){
684 const UChar* src = input[i];
685 int32_t srcLen = u_strlen(src);
686 UChar* dest = output;
687 int32_t destLen = 40;
688 UErrorCode status = U_ZERO_ERROR;
691 destLen = uidna_toASCII(src, srcLen, dest, destLen,UIDNA_DEFAULT, &ps, &status);
692 if(U_FAILURE(status)){
693 log_err_status(status, "uidna_toASCII failed with error %s.\n", u_errorName(status));
696 if(u_strncmp(input[i], dest, srcLen)!=0){
697 log_err("uidna_toASCII did not return the expected output.\n");
702 static void TestLength(){
704 static const char* cl = "my_very_very_very_very_very_very_very_very_very_very_very_very_very_long_and_incredibly_uncreative_domain_label";
705 UChar ul[128] = {'\0'};
706 UChar dest[256] = {'\0'};
707 /* this unicode string is longer than MAX_LABEL_BUFFER_SIZE and produces an
708 IDNA prepared string (including xn--)that is exactly 63 bytes long */
709 UChar ul1[] = { 0xC138, 0xACC4, 0xC758, 0xBAA8, 0xB4E0, 0xC0AC, 0xB78C, 0xB4E4, 0xC774,
710 0xD55C, 0xAD6D, 0xC5B4, 0xB97C, 0xC774, 0x00AD, 0x034F, 0x1806, 0x180B,
711 0x180C, 0x180D, 0x200B, 0x200C, 0x200D, 0x2060, 0xFE00, 0xFE01, 0xFE02,
712 0xFE03, 0xFE04, 0xFE05, 0xFE06, 0xFE07, 0xFE08, 0xFE09, 0xFE0A, 0xFE0B,
713 0xFE0C, 0xFE0D, 0xFE0E, 0xFE0F, 0xFEFF, 0xD574, 0xD55C, 0xB2E4, 0xBA74,
714 0xC138, 0x0041, 0x00AD, 0x034F, 0x1806, 0x180B, 0x180C, 0x180D, 0x200B,
715 0x200C, 0x200D, 0x2060, 0xFE00, 0xFE01, 0xFE02, 0xFE03, 0xFE04, 0xFE05,
716 0xFE06, 0xFE07, 0xFE08, 0xFE09, 0xFE0A, 0xFE0B, 0xFE0C, 0xFE0D, 0xFE0E,
717 0xFE0F, 0xFEFF, 0x00AD, 0x034F, 0x1806, 0x180B, 0x180C, 0x180D, 0x200B,
718 0x200C, 0x200D, 0x2060, 0xFE00, 0xFE01, 0xFE02, 0xFE03, 0xFE04, 0xFE05,
719 0xFE06, 0xFE07, 0xFE08, 0xFE09, 0xFE0A, 0xFE0B, 0xFE0C, 0xFE0D, 0xFE0E,
720 0xFE0F, 0xFEFF, 0x00AD, 0x034F, 0x1806, 0x180B, 0x180C, 0x180D, 0x200B,
721 0x200C, 0x200D, 0x2060, 0xFE00, 0xFE01, 0xFE02, 0xFE03, 0xFE04, 0xFE05,
722 0xFE06, 0xFE07, 0xFE08, 0xFE09, 0xFE0A, 0xFE0B, 0xFE0C, 0xFE0D, 0xFE0E,
723 0xFE0F, 0xFEFF, 0x0000
726 int32_t len1 = LENGTHOF(ul1)-1/*remove the null termination*/;
727 int32_t destLen = LENGTHOF(dest);
728 UErrorCode status = U_ZERO_ERROR;
730 int32_t len = (int32_t)strlen(cl);
731 u_charsToUChars(cl, ul, len+1);
732 destLen = uidna_toUnicode(ul, len, dest, destLen, UIDNA_DEFAULT, &ps, &status);
733 if(status != U_ZERO_ERROR){
734 log_err_status(status, "uidna_toUnicode failed with error %s.\n", u_errorName(status));
737 status = U_ZERO_ERROR;
738 destLen = LENGTHOF(dest);
740 destLen = uidna_toUnicode(ul, len, dest, destLen, UIDNA_DEFAULT, &ps, &status);
741 if(status != U_ZERO_ERROR){
742 log_err_status(status, "uidna_toUnicode failed with error %s.\n", u_errorName(status));
744 status = U_ZERO_ERROR;
745 destLen = LENGTHOF(dest);
746 len = (int32_t)strlen(cl);
747 destLen = uidna_toASCII(ul, len, dest, destLen, UIDNA_DEFAULT, &ps, &status);
748 if(status != U_IDNA_LABEL_TOO_LONG_ERROR){
749 log_err_status(status, "uidna_toASCII failed with error %s.\n", u_errorName(status));
752 status = U_ZERO_ERROR;
753 destLen = LENGTHOF(dest);
755 destLen = uidna_toASCII(ul, len, dest, destLen, UIDNA_DEFAULT, &ps, &status);
756 if(status != U_IDNA_LABEL_TOO_LONG_ERROR){
757 log_err_status(status, "uidna_toASCII failed with error %s.\n", u_errorName(status));
760 status = U_ZERO_ERROR;
761 destLen = LENGTHOF(dest);
762 destLen = uidna_toASCII(ul1, len1, dest, destLen, UIDNA_DEFAULT, &ps, &status);
763 if(status != U_ZERO_ERROR){
764 log_err_status(status, "uidna_toASCII failed with error %s.\n", u_errorName(status));
767 status = U_ZERO_ERROR;
768 destLen = LENGTHOF(dest);
770 destLen = uidna_toASCII(ul1, len1, dest, destLen, UIDNA_DEFAULT, &ps, &status);
771 if(status != U_ZERO_ERROR){
772 log_err_status(status, "uidna_toASCII failed with error %s.\n", u_errorName(status));
776 static const char* cl = "my_very_very_long_and_incredibly_uncreative_domain_label.my_very_very_long_and_incredibly_uncreative_domain_label.my_very_very_long_and_incredibly_uncreative_domain_label.my_very_very_long_and_incredibly_uncreative_domain_label.my_very_very_long_and_incredibly_uncreative_domain_label.my_very_very_long_and_incredibly_uncreative_domain_label.ibm.com";
777 UChar ul[400] = {'\0'};
778 UChar dest[400] = {'\0'};
779 int32_t destLen = LENGTHOF(dest);
780 UErrorCode status = U_ZERO_ERROR;
782 int32_t len = (int32_t)strlen(cl);
783 u_charsToUChars(cl, ul, len+1);
785 destLen = uidna_IDNToUnicode(ul, len, dest, destLen, UIDNA_DEFAULT, &ps, &status);
786 if(status != U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR){
787 log_err_status(status, "uidna_IDNToUnicode failed with error %s.\n", u_errorName(status));
790 status = U_ZERO_ERROR;
791 destLen = LENGTHOF(dest);
793 destLen = uidna_IDNToUnicode(ul, len, dest, destLen, UIDNA_DEFAULT, &ps, &status);
794 if(status != U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR){
795 log_err_status(status, "uidna_IDNToUnicode failed with error %s.\n", u_errorName(status));
798 status = U_ZERO_ERROR;
799 destLen = LENGTHOF(dest);
800 len = (int32_t)strlen(cl);
801 destLen = uidna_IDNToASCII(ul, len, dest, destLen, UIDNA_DEFAULT, &ps, &status);
802 if(status != U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR){
803 log_err_status(status, "uidna_IDNToASCII failed with error %s.\n", u_errorName(status));
806 status = U_ZERO_ERROR;
807 destLen = LENGTHOF(dest);
809 destLen = uidna_IDNToASCII(ul, len, dest, destLen, UIDNA_DEFAULT, &ps, &status);
810 if(status != U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR){
811 log_err_status(status, "uidna_IDNToASCII failed with error %s.\n", u_errorName(status));
814 status = U_ZERO_ERROR;
815 uidna_compare(ul, len, ul, len, UIDNA_DEFAULT, &status);
816 if(status != U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR){
817 log_err_status(status, "uidna_compare failed with error %s.\n", u_errorName(status));
819 uidna_compare(ul, -1, ul, -1, UIDNA_DEFAULT, &status);
820 if(status != U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR){
821 log_err_status(status, "uidna_compare failed with error %s.\n", u_errorName(status));
825 static void TestJB5273(){
826 static const char INVALID_DOMAIN_NAME[] = "xn--m\\u00FCller.de";
827 UChar invalid_idn[25] = {'\0'};
828 int32_t len = u_unescape(INVALID_DOMAIN_NAME, invalid_idn, strlen(INVALID_DOMAIN_NAME));
829 UChar output[50] = {'\0'};
830 UErrorCode status = U_ZERO_ERROR;
831 UParseError prsError;
832 int32_t outLen = uidna_toUnicode(invalid_idn, len, output, 50, UIDNA_DEFAULT, &prsError, &status);
833 (void)outLen; /* Suppress set but not used warning. */
834 if(U_FAILURE(status)){
835 log_err_status(status, "uidna_toUnicode failed with error: %s\n", u_errorName(status));
837 status = U_ZERO_ERROR;
838 outLen = uidna_toUnicode(invalid_idn, len, output, 50, UIDNA_USE_STD3_RULES, &prsError, &status);
839 if(U_FAILURE(status)){
840 log_err_status(status, "uidna_toUnicode failed with error: %s\n", u_errorName(status));
843 status = U_ZERO_ERROR;
844 outLen = uidna_IDNToUnicode(invalid_idn, len, output, 50, UIDNA_DEFAULT, &prsError, &status);
845 if(U_FAILURE(status)){
846 log_err_status(status, "uidna_toUnicode failed with error: %s\n", u_errorName(status));
848 status = U_ZERO_ERROR;
849 outLen = uidna_IDNToUnicode(invalid_idn, len, output, 50, UIDNA_USE_STD3_RULES, &prsError, &status);
850 if(U_FAILURE(status)){
851 log_err_status(status, "uidna_toUnicode failed with error: %s\n", u_errorName(status));
856 * Test the new (ICU 4.6/2010) C API that was added for UTS #46.
857 * Just an API test: Functionality is tested via C++ intltest.
859 static void TestUTS46() {
860 static const UChar fA_sharps16[] = { 0x66, 0x41, 0xdf, 0 };
861 static const char fA_sharps8[] = { 0x66, 0x41, (char)0xc3, (char)0x9f, 0 };
862 static const UChar fa_sharps16[] = { 0x66, 0x61, 0xdf, 0 };
863 static const char fa_sharps8[] = { 0x66, 0x61, (char)0xc3, (char)0x9f, 0 };
864 static const UChar fass16[] = { 0x66, 0x61, 0x73, 0x73, 0 };
865 static const char fass8[] = { 0x66, 0x61, 0x73, 0x73, 0 };
866 static const UChar fA_BEL[] = { 0x66, 0x41, 7, 0 };
867 static const UChar fa_FFFD[] = { 0x66, 0x61, 0xfffd, 0 };
873 UIDNAInfo info = UIDNA_INFO_INITIALIZER;
874 UErrorCode errorCode = U_ZERO_ERROR;
875 UIDNA *uts46 = uidna_openUTS46(UIDNA_USE_STD3_RULES|UIDNA_NONTRANSITIONAL_TO_UNICODE,
877 if(U_FAILURE(errorCode)) {
878 log_err_status(errorCode, "uidna_openUTS46() failed: %s\n", u_errorName(errorCode));
882 /* These calls should succeed. */
883 length = uidna_labelToASCII(uts46, fA_sharps16, -1,
884 dest16, LENGTHOF(dest16), &info, &errorCode);
885 if( U_FAILURE(errorCode) || length != 4 || 0 != u_memcmp(dest16, fass16, 5) ||
886 !info.isTransitionalDifferent || info.errors != 0
888 log_err("uidna_labelToASCII() failed: %s\n", u_errorName(errorCode));
890 errorCode = U_ZERO_ERROR;
891 length = uidna_labelToUnicode(uts46, fA_sharps16, u_strlen(fA_sharps16),
892 dest16, LENGTHOF(dest16), &info, &errorCode);
893 if( U_FAILURE(errorCode) || length != 3 || 0 != u_memcmp(dest16, fa_sharps16, 4) ||
894 !info.isTransitionalDifferent || info.errors != 0
896 log_err("uidna_labelToUnicode() failed: %s\n", u_errorName(errorCode));
898 errorCode = U_ZERO_ERROR;
899 length = uidna_nameToASCII(uts46, fA_sharps16, u_strlen(fA_sharps16),
900 dest16, 4, &info, &errorCode);
901 if( errorCode != U_STRING_NOT_TERMINATED_WARNING ||
902 length != 4 || 0 != u_memcmp(dest16, fass16, 4) ||
903 !info.isTransitionalDifferent || info.errors != 0
905 log_err("uidna_nameToASCII() failed: %s\n", u_errorName(errorCode));
907 errorCode = U_ZERO_ERROR;
908 length = uidna_nameToUnicode(uts46, fA_sharps16, -1,
909 dest16, 3, &info, &errorCode);
910 if( errorCode != U_STRING_NOT_TERMINATED_WARNING ||
911 length != 3 || 0 != u_memcmp(dest16, fa_sharps16, 3) ||
912 !info.isTransitionalDifferent || info.errors != 0
914 log_err("uidna_nameToUnicode() failed: %s\n", u_errorName(errorCode));
917 errorCode = U_ZERO_ERROR;
918 length = uidna_labelToASCII_UTF8(uts46, fA_sharps8, -1,
919 dest8, LENGTHOF(dest8), &info, &errorCode);
920 if( U_FAILURE(errorCode) || length != 4 || 0 != memcmp(dest8, fass8, 5) ||
921 !info.isTransitionalDifferent || info.errors != 0
923 log_err("uidna_labelToASCII_UTF8() failed: %s\n", u_errorName(errorCode));
925 errorCode = U_ZERO_ERROR;
926 length = uidna_labelToUnicodeUTF8(uts46, fA_sharps8, strlen(fA_sharps8),
927 dest8, LENGTHOF(dest8), &info, &errorCode);
928 if( U_FAILURE(errorCode) || length != 4 || 0 != memcmp(dest8, fa_sharps8, 5) ||
929 !info.isTransitionalDifferent || info.errors != 0
931 log_err("uidna_labelToUnicodeUTF8() failed: %s\n", u_errorName(errorCode));
933 errorCode = U_ZERO_ERROR;
934 length = uidna_nameToASCII_UTF8(uts46, fA_sharps8, strlen(fA_sharps8),
935 dest8, 4, &info, &errorCode);
936 if( errorCode != U_STRING_NOT_TERMINATED_WARNING ||
937 length != 4 || 0 != memcmp(dest8, fass8, 4) ||
938 !info.isTransitionalDifferent || info.errors != 0
940 log_err("uidna_nameToASCII_UTF8() failed: %s\n", u_errorName(errorCode));
942 errorCode = U_ZERO_ERROR;
943 length = uidna_nameToUnicodeUTF8(uts46, fA_sharps8, -1,
944 dest8, 4, &info, &errorCode);
945 if( errorCode != U_STRING_NOT_TERMINATED_WARNING ||
946 length != 4 || 0 != memcmp(dest8, fa_sharps8, 4) ||
947 !info.isTransitionalDifferent || info.errors != 0
949 log_err("uidna_nameToUnicodeUTF8() failed: %s\n", u_errorName(errorCode));
952 errorCode = U_ZERO_ERROR;
953 length = uidna_nameToASCII(uts46, NULL, 0,
954 dest16, 0, &info, &errorCode);
955 if( errorCode != U_STRING_NOT_TERMINATED_WARNING ||
957 info.isTransitionalDifferent || info.errors != UIDNA_ERROR_EMPTY_LABEL
959 log_err("uidna_nameToASCII(empty) failed: %s\n", u_errorName(errorCode));
961 errorCode = U_ZERO_ERROR;
962 length = uidna_nameToUnicode(uts46, fA_BEL, -1,
963 dest16, 3, &info, &errorCode);
964 if( errorCode != U_STRING_NOT_TERMINATED_WARNING ||
965 length != 3 || 0 != u_memcmp(dest16, fa_FFFD, 3) ||
966 info.isTransitionalDifferent || info.errors == 0
968 log_err("uidna_nameToUnicode(fa<BEL>) failed: %s\n", u_errorName(errorCode));
971 /* These calls should fail. */
972 errorCode = U_USELESS_COLLATOR_ERROR;
973 length = uidna_labelToASCII(uts46, fA_sharps16, -1,
974 dest16, LENGTHOF(dest16), &info, &errorCode);
975 if(errorCode != U_USELESS_COLLATOR_ERROR) {
976 log_err("uidna_labelToASCII(failure) failed: %s\n", u_errorName(errorCode));
978 errorCode = U_ZERO_ERROR;
979 length = uidna_labelToUnicode(uts46, fA_sharps16, u_strlen(fA_sharps16),
980 dest16, LENGTHOF(dest16), NULL, &errorCode);
981 if(errorCode != U_ILLEGAL_ARGUMENT_ERROR) {
982 log_err("uidna_labelToUnicode(UIDNAInfo=NULL) failed: %s\n", u_errorName(errorCode));
984 errorCode = U_ZERO_ERROR;
985 length = uidna_nameToASCII(uts46, NULL, u_strlen(fA_sharps16),
986 dest16, 4, &info, &errorCode);
987 if(errorCode != U_ILLEGAL_ARGUMENT_ERROR) {
988 log_err("uidna_nameToASCII(src=NULL) failed: %s\n", u_errorName(errorCode));
990 errorCode = U_ZERO_ERROR;
991 length = uidna_nameToUnicode(uts46, fA_sharps16, -2,
992 dest16, 3, &info, &errorCode);
993 if(errorCode != U_ILLEGAL_ARGUMENT_ERROR) {
994 log_err("uidna_nameToUnicode(length<-1) failed: %s\n", u_errorName(errorCode));
997 errorCode = U_ZERO_ERROR;
998 length = uidna_labelToASCII_UTF8(uts46, fA_sharps8, -1,
999 NULL, LENGTHOF(dest8), &info, &errorCode);
1000 if(errorCode != U_ILLEGAL_ARGUMENT_ERROR) {
1001 log_err("uidna_labelToASCII_UTF8(dest=NULL) failed: %s\n", u_errorName(errorCode));
1003 errorCode = U_ZERO_ERROR;
1004 length = uidna_labelToUnicodeUTF8(uts46, fA_sharps8, strlen(fA_sharps8),
1005 dest8, -1, &info, &errorCode);
1006 if(errorCode != U_ILLEGAL_ARGUMENT_ERROR) {
1007 log_err("uidna_labelToUnicodeUTF8(capacity<0) failed: %s\n", u_errorName(errorCode));
1009 errorCode = U_ZERO_ERROR;
1010 length = uidna_nameToASCII_UTF8(uts46, dest8, strlen(fA_sharps8),
1011 dest8, 4, &info, &errorCode);
1012 if(errorCode != U_ILLEGAL_ARGUMENT_ERROR) {
1013 log_err("uidna_nameToASCII_UTF8(src==dest!=NULL) failed: %s\n", u_errorName(errorCode));
1015 errorCode = U_ZERO_ERROR;
1016 length = uidna_nameToUnicodeUTF8(uts46, fA_sharps8, -1,
1017 dest8, 3, &info, &errorCode);
1018 if(errorCode != U_BUFFER_OVERFLOW_ERROR || length != 4) {
1019 log_err("uidna_nameToUnicodeUTF8() overflow failed: %s\n", u_errorName(errorCode));
1028 * Hey, Emacs, please set the following:
1031 * indent-tabs-mode: nil