// Intercept string
Public static string getStr (string s, int l)
{
String temp = s;
If (Regex. Replace (temp, "[\ u4e00-\ u9fa5]", "zz", RegexOptions. IgnoreCase). Length <= l)
{
Return temp;
}
For (int I = temp. Length; I> = 0; I --)
{
Temp = temp. Substring (0, I );
If (Regex. Replace (temp, "[\ u4e00-\ u9fa5]", "zz", RegexOptions. IgnoreCase). Length <= l-3)
{
Return temp + "...";
}
}
Return "...";
}
C # Chinese Character truncation Function
/// Str_value
/// Str_len
Public string leftx (string str_value, int str_len)
{
Int p_num = 0;
Int I;
String New_Str_value = "";
If (str_value = "")
{
New_Str_value = "";
}
Else
{
Int Len_Num = str_value.Length;
// If (Len_Num <str_len)
//{
// Str_len = Len_Num;
//}
For (I = 0; I <= Len_Num-1; I ++)
{
// Str_value.Substring (I, 1 );
If (I> Len_Num) break;
Char c = Convert. ToChar (str_value.Substring (I, 1 ));
If (int) c> 255) | (int) c <0 ))
{
P_num = p_num + 2;
}
Else
{
P_num = p_num + 1;
}
If (p_num> = str_len)
{
New_Str_value = str_value.Substring (0, I + 1 );
Break;
}
Else
{
New_Str_value = str_value;
}
}
}
Return New_Str_value;
}
// Automatic line feed of data
<Table>
<Tr>
<Td style = "word-wrap: break-word; width = 100">
The bound data is displayed as is. If the length exceeds 100, the data is automatically folded.
</Td>
</Tr>
</Table>
From hcstudio