2000-01-15 02:00:06 +00:00
|
|
|
/********************************************************************
|
|
|
|
* COPYRIGHT:
|
2001-03-21 19:46:49 +00:00
|
|
|
* Copyright (c) 2001, International Business Machines Corporation and
|
2000-01-15 02:00:06 +00:00
|
|
|
* others. All Rights Reserved.
|
|
|
|
********************************************************************/
|
1999-12-28 23:57:50 +00:00
|
|
|
#include "unicode/utypes.h"
|
|
|
|
#include "unicode/ustring.h"
|
2000-01-17 22:53:44 +00:00
|
|
|
#include "unicode/ctest.h"
|
1999-12-28 23:57:50 +00:00
|
|
|
#include "unicode/ucnv.h"
|
1999-10-22 23:45:55 +00:00
|
|
|
|
1999-12-22 22:57:04 +00:00
|
|
|
void TestEuroRegression(void);
|
2001-05-31 23:20:21 +00:00
|
|
|
void addTestEuroRegression(TestNode** root);
|
|
|
|
|
1999-10-22 23:45:55 +00:00
|
|
|
void addTestEuroRegression(TestNode** root)
|
|
|
|
{
|
|
|
|
addTest(root, &TestEuroRegression, "tsconv/eurocreg/TestEuroRegression");
|
|
|
|
}
|
|
|
|
|
2000-11-28 21:30:32 +00:00
|
|
|
/*
|
|
|
|
* The table below lists codepages that are supposed to have roundtrip mappings for
|
|
|
|
* the U+20AC Euro sign.
|
|
|
|
*
|
|
|
|
* Changes made 2000nov28 and marked as such are due to the following:
|
|
|
|
*
|
|
|
|
* After updating all ibm-*.ucm files with precise fallback indicators (|0, |1, |3),
|
|
|
|
* some of these codepages failed the Euro regression test.
|
|
|
|
* This means that the actuall mappings changed when only the preciseness of fallback
|
|
|
|
* mappings should have changed.
|
|
|
|
* My (Markus) suspicion is that some files got Euro sign mappings added manually,
|
|
|
|
* changing their contents compared to the NLTC (IBM Toronto codepage database) definition.
|
|
|
|
* Such changes are highly undesirable because they effectively define new codepages.
|
|
|
|
* Codepage mapping files with "ibm-*.ucm" should always exactly match the files
|
|
|
|
* from the IBM codepage database.
|
|
|
|
* (If there are several mappings with the same number, then we choose the
|
|
|
|
* default mappings with Private-Use Area assignments.)
|
|
|
|
*
|
|
|
|
* Also, in the past, some aliases were set such that e.g. cp850 became an alias for ibm-858.
|
|
|
|
* This followed the practice of OS/2 that uses the old codepage number 850 for the new
|
|
|
|
* codepage 858, with the main difference being the additional Euro sign.
|
|
|
|
* However, we have documented that the "cp" prefix should be used for Microsoft-compatible
|
|
|
|
* codepages, and Microsoft Windows 2000's codepage 850 does not contain a Euro sign mapping.
|
|
|
|
* Therefore, cp850 must not support the Euro sign.
|
|
|
|
* In these cases, I have changed the codepage name here to point to a newer codepage with the
|
|
|
|
* Euro sign, using its new name.
|
|
|
|
* I could not find such "updates" for codepages 1362 and 1363 - we might want to supply them later.
|
|
|
|
*/
|
|
|
|
|
1999-10-22 23:45:55 +00:00
|
|
|
char convertersToCheck[][15] = {
|
|
|
|
"cp1250",
|
|
|
|
"cp1251",
|
|
|
|
"cp1252",
|
|
|
|
"cp1254",
|
|
|
|
"cp1255",
|
|
|
|
"cp1256",
|
|
|
|
"cp1257",
|
|
|
|
"cp1258",
|
2000-02-16 01:33:45 +00:00
|
|
|
"ibm1140",
|
|
|
|
"ibm1142",
|
|
|
|
"ibm1143",
|
|
|
|
"ibm1144",
|
|
|
|
"ibm1145",
|
|
|
|
"ibm1146",
|
|
|
|
"ibm1147",
|
|
|
|
"ibm1148",
|
|
|
|
"ibm1149",
|
|
|
|
"ibm1153",
|
2002-07-03 18:42:43 +00:00
|
|
|
"ibm1154",
|
|
|
|
"ibm1155",
|
|
|
|
"ibm1156",
|
|
|
|
"ibm1157",
|
|
|
|
"ibm1158",
|
|
|
|
"ibm-1159",
|
2000-02-16 01:33:45 +00:00
|
|
|
"ibm12712",
|
|
|
|
"ibm16804",
|
2002-07-03 18:42:43 +00:00
|
|
|
"ibm-1160",
|
|
|
|
"ibm-1162",
|
|
|
|
"ibm-1164",
|
|
|
|
|
2000-11-28 21:30:32 +00:00
|
|
|
"ibm-858", /* was "cp850" changed 2000nov28 */
|
|
|
|
/* duplicate "cp850" removed 2000nov28 */
|
1999-10-22 23:45:55 +00:00
|
|
|
"cp857",
|
2000-11-28 21:30:32 +00:00
|
|
|
"ibm-12712", /* was "cp424" changed 2000nov28 */
|
|
|
|
"ibm-4899", /* was "cp803" changed 2000nov28 */
|
1999-10-22 23:45:55 +00:00
|
|
|
"cp862",
|
|
|
|
"cp1258",
|
|
|
|
"cp950",
|
|
|
|
"cp1253",
|
|
|
|
/* "cp819",
|
|
|
|
"cp13488",*/
|
2001-02-27 01:04:08 +00:00
|
|
|
"cpibm4971",
|
1999-10-22 23:45:55 +00:00
|
|
|
"cp869",
|
2002-08-28 15:43:47 +00:00
|
|
|
/* "cp813",*/
|
1999-10-22 23:45:55 +00:00
|
|
|
"cp852",
|
|
|
|
"cp855",
|
|
|
|
"cp866",
|
|
|
|
"cp1131",
|
|
|
|
"cp1125",
|
|
|
|
"cp922",
|
|
|
|
"cp921",
|
|
|
|
"cp864",
|
|
|
|
"cp1008",
|
|
|
|
"cp1046",
|
|
|
|
/* "cp9066",
|
|
|
|
"cp1129",*/
|
|
|
|
"cp1027",
|
2002-07-31 22:19:45 +00:00
|
|
|
/* "cp300",*/
|
|
|
|
/* "cp4930",*/
|
2002-07-03 18:42:43 +00:00
|
|
|
"cp1364",
|
|
|
|
/* "cp1362" removed 2000nov28 */
|
|
|
|
"cp1363",
|
|
|
|
/* "cp1114", removed 2002jul3
|
|
|
|
"cp947", removed 2002jul3 */
|
|
|
|
"gb18030",
|
1999-10-22 23:45:55 +00:00
|
|
|
""};
|
|
|
|
|
2001-09-28 22:22:59 +00:00
|
|
|
UBool isEuroAware(UConverter*);
|
1999-10-22 23:45:55 +00:00
|
|
|
|
|
|
|
void TestEuroRegression()
|
|
|
|
{
|
2000-11-21 04:05:39 +00:00
|
|
|
int32_t i=0;
|
|
|
|
|
|
|
|
do
|
1999-10-22 23:45:55 +00:00
|
|
|
{
|
2000-11-21 04:05:39 +00:00
|
|
|
UErrorCode err = U_ZERO_ERROR;
|
|
|
|
UConverter* myConv = ucnv_open(convertersToCheck[i], &err);
|
|
|
|
if (U_FAILURE(err)&&convertersToCheck[i][0])
|
2002-09-20 19:07:19 +00:00
|
|
|
log_data_err("%s \tMISSING [%s]\n", convertersToCheck[i], u_errorName(err));
|
2000-11-21 04:05:39 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (isEuroAware(myConv))
|
|
|
|
log_verbose("%s \tsupports euro\n", convertersToCheck[i]);
|
|
|
|
else
|
|
|
|
log_err("%s \tDOES NOT support euro\n", convertersToCheck[i]);
|
|
|
|
ucnv_close(myConv);
|
|
|
|
}
|
1999-10-22 23:45:55 +00:00
|
|
|
} while (convertersToCheck[++i][0]);
|
|
|
|
}
|
|
|
|
|
2001-09-28 22:22:59 +00:00
|
|
|
UBool isEuroAware(UConverter* myConv)
|
1999-10-22 23:45:55 +00:00
|
|
|
{
|
2000-11-21 04:05:39 +00:00
|
|
|
static const UChar euroString[2] = { 0x20AC, 0x0000 };
|
2001-09-28 22:22:59 +00:00
|
|
|
char target[20];
|
2000-11-21 04:05:39 +00:00
|
|
|
UChar euroBack[2];
|
|
|
|
int32_t targetSize, euroBackSize;
|
|
|
|
UErrorCode err = U_ZERO_ERROR;
|
|
|
|
/*const char* myName = ucnv_getName(myConv, &err);*/
|
1999-10-22 23:45:55 +00:00
|
|
|
|
2000-11-21 04:05:39 +00:00
|
|
|
targetSize = ucnv_fromUChars(myConv,
|
|
|
|
target,
|
2001-09-28 22:22:59 +00:00
|
|
|
sizeof(target),
|
2000-11-21 04:05:39 +00:00
|
|
|
euroString,
|
|
|
|
-1,
|
|
|
|
&err);
|
|
|
|
if (U_FAILURE(err))
|
1999-10-22 23:45:55 +00:00
|
|
|
{
|
|
|
|
log_err("Failure Occured in ucnv_fromUChars euro roundtrip test\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2000-11-21 04:05:39 +00:00
|
|
|
euroBackSize = ucnv_toUChars(myConv,
|
|
|
|
euroBack,
|
|
|
|
2,
|
|
|
|
target,
|
|
|
|
targetSize,
|
|
|
|
&err);
|
|
|
|
if (U_FAILURE(err))
|
1999-10-22 23:45:55 +00:00
|
|
|
{
|
2000-11-21 04:05:39 +00:00
|
|
|
log_err("Failure Occured in ucnv_toUChars euro roundtrip test\n");
|
|
|
|
return FALSE;
|
1999-10-22 23:45:55 +00:00
|
|
|
}
|
2000-11-21 04:05:39 +00:00
|
|
|
if (u_strcmp(euroString, euroBack))
|
1999-10-22 23:45:55 +00:00
|
|
|
{
|
2000-11-21 04:05:39 +00:00
|
|
|
/* log_err("%s FAILED Euro rountrip\n", myName);*/
|
|
|
|
return FALSE;
|
1999-10-22 23:45:55 +00:00
|
|
|
}
|
2000-11-21 04:05:39 +00:00
|
|
|
else
|
1999-10-22 23:45:55 +00:00
|
|
|
{
|
2000-11-21 04:05:39 +00:00
|
|
|
/* log_verbose("%s PASSED Euro rountrip\n", myName);*/
|
|
|
|
return TRUE;
|
1999-10-22 23:45:55 +00:00
|
|
|
}
|
2000-11-21 04:05:39 +00:00
|
|
|
|
1999-10-22 23:45:55 +00:00
|
|
|
}
|