934
社区成员
发帖
与我相关
我的任务
分享
void StrPtrLen::PrintStrEOL(char* stopStr, char *appendStr)
{
char *thestr = GetAsCString();
SInt32 i = 0;
for (; i < (SInt32) Len; i ++) //for循环,保留thestr中没有被禁止打印的字符
{
if (StrPtrLen::sNonPrintChars[Ptr[i]])
{ thestr[i] = 0;
break;
}
}
for (i = 0; thestr[i] != 0 ; i ++)
{
if (thestr[i] == '%' && thestr[i+1] != '%' )
{ thestr[i] = '$';
}
} //单"%"转"$",这步处理这是为什么呢?
SInt32 stopLen = 0;
if (stopStr != NULL)
stopLen = ::strlen(stopStr);
if (stopLen > 0 && stopLen <= i)
{
char* stopPtr = ::strstr(thestr, stopStr);//搜索stopStr在theStr中的第一次出现。找到所搜索的字符串则返回字符串的地址。
if (stopPtr != NULL)
{ stopPtr += stopLen;
*stopPtr = 0;
i = stopPtr - thestr;
}
}
char * theStrLine = thestr;
char * nextLine = NULL;
char * theChar = NULL;
static char *cr="\\r";
static char *lf="\\n\n";
SInt32 tempLen = i;
for (i = 0; i < tempLen; i ++)
{
if (theStrLine[i] == '\r')
{ theChar = cr;
theStrLine[i] = 0;
nextLine = &theStrLine[i+1];
}
else if (theStrLine[i] == '\n')
{ theChar = lf;
theStrLine[i] = 0;
nextLine = &theStrLine[i+1];
}
if (nextLine != NULL)
{
qtss_printf(theStrLine);
qtss_printf(theChar);
theStrLine = nextLine;
nextLine = NULL;
tempLen -= (i+1);
i = -1;
}
}
qtss_printf(theStrLine);
delete thestr;
if (appendStr != NULL)
qtss_printf(appendStr);
}
for (i = 0; thestr[i] != 0 ; i ++)
{
if (thestr[i] == '%' && thestr[i+1] != '%' )
{ thestr[i] = '$';
}
}