This function is used in mkdcppw.
- Code: Tout sélectionner
// ****************************************************************************
//O ISO2UString ()
// ****************************************************************************
Glib::ustring Mkdcppw::ISO2UString(char string[])
{
Glib::ustring strOut = "";
char buffer[3] = {'\0', '\0','\0'};
long llen=strlen(string);
long li;
int ch1=0;
//T if (is_utf8(string) ) return ""; //T used only on mkdcppw
if(v) puts("test for convertion ISO to UTF8");
for(li=0; li<llen; li++)
{
ch1=string[li];
if(v) printf("%x=%c, ",ch1,ch1); //T test point
//T std::cout << "str = " << strOut << std::endl; //T test point
if(ch1 < 0x80 && ch1 > 0x00)
{
buffer[0] = ch1;
buffer[1] = '\0';
//T printf("buffer= %s\n",buffer); //T test point
strOut += buffer;
}
else if (ch1 > 0xffffff8f && ch1 < 0xffffffc0)
{
buffer[0] = 0xc2;
buffer[1] = ch1-0xffffff00;
//T printf("ISO char = %x %x\n",buffer[0], buffer[1]); //T test point
strOut += buffer;
}
else if (ch1 > 0xffffffbf && ch1 < 0xffffffff)
{
buffer[0] = 0xc3;
buffer[1] = ch1 - 0xffffff40;
//T printf("ISO char = %x %x\n",buffer[0], buffer[1]); //T test point
strOut += buffer;
}
else if (ch1 == 0xffffffff)
{
buffer[0] = 0xdf;
buffer[1] = 0xbf;
strOut += buffer;
}
else
{
if(v) puts("not ISO string");
return ""; //P not ISO string
}
}
return strOut;
}