I want to create an converter from memory.
I have created the etrypoint_dat and then the c file from my converter and joined the two struct together:
},
"", 1, 0, {
{ "ibm-5348_P100-1997", (const void *)&ibm_5348_P100_1997_cnv }
}
From the code I c开发者_开发问答all
udata_setAppData("icupackage.dat", &ntrypoint_dat, &status); // return is good
Now my question: How do I create the converter after the call fo setAppData?
The following does not work:
UConverter* conv = ucnv_open("ibm-5348_P100-1997", &status);
I found it myself.
The connection between the two structs must be named in this way:
{ "icupackage.dat/ibm-5348_P100-1997.cnv", (const void *)&ibm_5348_P100_1997_cnv },
then from code we can call:
status = U_ZERO_ERROR;
udata_setAppData("icupackage.dat", &ntrypoint_dat, &status);
and then:
status = U_ZERO_ERROR;
_cnvCP1252 = ucnv_openPackage("windows", "ibm-5348_P100-1997.cnv", &status);
The .dat
should be deleted. I leave it for consistences with the question.
I would instead suggest that you use the pkgdata tool with mode 'static' which will build a static library for you to link. This other example is the undocumented and fragile fragile way.
精彩评论