Function to intercept Chinese characters into one word and English into one word.
If you have any questions, please advise
/// <Summary>
/// Word truncation Function
/// </Summary>
/// <Param name = "splitstr"> string </param>
/// <Param name = "splitletter"> Number of truncated words </param>
/// <Returns> </returns>
Public String splitstring (string splitstr, int splitletter)
{
Int maxlength = splitletter * 2;
Int splitlpointer = splitletter;
Int splitlenght = splitstr. length;
String strafter = "";
If (splitlenght <splitletter)
Return splitstr;
If (splitletter <= 0)
Return string. empty;
If (system. Text. encoding. getencoding ("gb2312"). getbytes (splitstr). length> maxlength)
{Strafter = "...";}
Char [] splitchr = splitstr. tochararray ();
String splittemp = string. empty;
For (INT I = 0; I <splitlenght; I ++)
{
If (I = splitlpointer | I> = maxlength)
{Return splittemp + strafter ;}
Char splititem = splitchr [I];
Splittemp + = splititem. tostring ();
If (system. Text. encoding. getencoding ("gb2312"). getbytes (splititem. tostring (). Length = 1)
{Splitlpointer ++ ;}
Else if (system. Text. encoding. getencoding ("gb2312"). getbytes (splititem. tostring (). Length = 2)
{
If (splitlpointer = splitletter)
{
If (I + 2> splitlpointer)
{Return splittemp + strafter ;}
}
Else {
If (I + 2> = splitlpointer)
{Return splittemp + strafter ;}
}
}
}
Return splitstr;
}