{
constunsignedshort * constuni2cp_low = table->uni2cp_low;
constunsignedshort * constuni2cp_high = table->uni2cp_high;
WCHAR defchar_value = table->info.def_char;
WCHAR composed;
intlen, tmp;
if (defchar) defchar_value = defchar[1] ? ((defchar[0] << 8) | defchar[1]) : defchar[0];
if (!used) used = &tmp; /* avoid checking on every char */
*used = 0;
for (len = dstlen; srclen && len; len--, srclen--, src++)
{
unsignedshortres;
WCHAR wch = *src;
if ((flags & WC_COMPOSITECHECK) && (srclen > 1) && (composed = compose(src)))
{
/* now check if we can use the composed char */
res = uni2cp_low[uni2cp_high[composed >> 8] + (composed & 0xff)];
if (is_valid_dbcs_mapping( table, flags, composed, res ))
{
/* we have a good mapping for the composed char, use it */src++;
srclen--;
goto output_char;
}
/* no mapping for the composed char, check the other flags */if (flags & WC_DEFAULTCHAR) /* use the default char instead */
{
res = defchar_value;
*used = 1;
src++; /* skip the non-spacing char */
srclen--;
goto output_char;
}
if (flags & WC_DISCARDNS) /* skip the second char of the composition */
{
src++;
srclen--;
}
/* WC_SEPCHARS is the default */
}
res = uni2cp_low[uni2cp_high[wch >> 8] + (wch & 0xff)];
if (!is_valid_dbcs_mapping( table, flags, wch, res ))
{
res = defchar_value;
*used = 1;
}
output_char:
if (res & 0xff00)
{
if (len == 1) break; /* do not output a partial char */
len--;
*dst++ = res >> 8;
}
*dst++ = (char)res;
}
if (srclen) return -1; /* overflow */return dstlen - len;
}
Generated on Sun May 27 2012 06:09:06 for ReactOS by
1.7.6.1
ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.