if (string)
uc_string.reserve(strlen(string));
- const char *p = string;
+ const char *p = string ? string : "";
- while(p)
+ while (*p)
{
unsigned int unicode=(unsigned char)*p++;
{
unicode&=0x1F;
unicode<<=6;
- if (p)
+ if (*p)
unicode|=(*p++)&0x3F;
} else if ((unicode & 0xF0)==0xE0) // three bytes
{
unicode&=0x0F;
unicode<<=6;
- if (p)
+ if (*p)
unicode|=(*p++)&0x3F;
unicode<<=6;
- if (p)
+ if (*p)
unicode|=(*p++)&0x3F;
} else if ((unicode & 0xF8)==0xF0) // four bytes
{
unicode&=0x07;
unicode<<=6;
- if (p)
+ if (*p)
unicode|=(*p++)&0x3F;
unicode<<=6;
- if (p)
+ if (*p)
unicode|=(*p++)&0x3F;
unicode<<=6;
- if (p)
+ if (*p)
unicode|=(*p++)&0x3F;
}
}