处理\n
This commit is contained in:
@@ -289,6 +289,15 @@ static NSUInteger kb_validUTF8PrefixLen(NSData *data) {
|
||||
- (void)emitChunk:(NSString *)rawText {
|
||||
if (rawText.length == 0) return;
|
||||
NSString *text = rawText;
|
||||
// 0) 规范化换行与段起始:去掉位于片段开头的 \r/\n;将 "\n\t"、"\r\n\t"、"\r\t" 归一为 "\t"
|
||||
text = [text stringByReplacingOccurrencesOfString:@"\r\n\t" withString:@"\t"];
|
||||
text = [text stringByReplacingOccurrencesOfString:@"\n\t" withString:@"\t"];
|
||||
text = [text stringByReplacingOccurrencesOfString:@"\r\t" withString:@"\t"];
|
||||
while (text.length > 0) {
|
||||
unichar c0 = [text characterAtIndex:0];
|
||||
if (c0 == '\n' || c0 == '\r') { text = [text substringFromIndex:1]; continue; }
|
||||
break;
|
||||
}
|
||||
// 1) 统一处理 “/t” -> “\t”
|
||||
if (self.treatSlashTAsTab) {
|
||||
text = [text stringByReplacingOccurrencesOfString:@"/t" withString:@"\t"];
|
||||
|
||||
Reference in New Issue
Block a user