自动换行模糊处理

#import "string.h"

const int COUNTS_OF_LINE = 93;

void cpytoend(char* str, char* pstart, char* pend)
{
	while (pstart != pend + 1)
	{
		*str = *pstart == '\n'? ' ': *pstart;//对换行符进行特殊处理
		pstart++;
		str++;
	}
	*str = '\0';
}

BOOL isEnd(char c)
{
	if (c == ' ' || c == ',' || c == '.')//可作为换行的标识字符
	{
		return YES;
	}
	else 
	{
		return NO;
	}
}
int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
	
	char strContent[2048] = {0};
	NSString * astring = The Remote Controller is an application that turns your iPad, "
	"iPhone or iPad touch into a remote control for your IPTV. \n"
	"jk's vision is to enrich people's lives through communication. By leveraging our experience and"
	"expertise in telecom sector,we help bridge the digtal "
	"digital divide and give people the opportunity to join the information age,regardless og their geographic origin. In order to tackle increasing 

climate "
	"challenges, jk has deployed a wide range of green solutions that enable customers to reduce power consumption and carbon emissions, contributing 

to the "
	"sustainable develoopment of the social economy and the environment.";
	
	strcpy(strContent, [astring UTF8String]);
		   char * pchstart = strContent;
		   char * pend = pchstart;
		   int number = 0;
		   while (*pend != '\0')
		   {
			   if (number <  COUNTS_OF_LINE)
			   {
				   if ( *pend == '\n' || *(pend + 1) == '\0')
				   {
					   char tmpstr[100] = {0};
					   cpytoend(tmpstr, pchstart, pend);
					   NSLog(@"======%s", tmpstr);
					   pchstart = pend + 1;
					   number = 0;
				   }
			   }
			   else 
			   {
				   if (isEnd(*pend) )
				   {
					   char tmpstr[100] = {0};
					   cpytoend(tmpstr, pchstart, pend);
					   NSLog(@"======%s", tmpstr);
					   pchstart = pend + 1;
					   number = 0;
				   }
			   }
			   number++;
			   pend++;
		   }

}


 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值