int iCnt = 0;
int i_index;
int i_len;
System.Text.StringBuilder strRet = new System.Text.StringBuilder();
i_len = strVal.Length;
byte[] chrbyte;
System.Text.Encoding encoding = System.Text.Encoding.Unicode;
chrbyte = encoding.GetBytes(strVal);
for (i_index = 1; i_index < (chrbyte.Length); i_index = i_index + 2)
{
iCnt++;
if (chrbyte[i_index] != 0)
{
iCnt++;
}
if (iCnt <= iLength)
{
byte[] va = new byte[2];
va[0] = chrbyte[i_index - 1];
va[1] = chrbyte[i_index];
strRet.Append(encoding.GetString(va));
}
else
{
if (i_index < chrbyte.Length + 1)
{
strRet.Append("...");
}
break;
}
}