Trim trailing '\0'
This commit is contained in:
2 files changed
+16
-2
No files matched your search
+15
-1
@@ -193,8 +193,22 @@
|
||||
}
|
||||
[sc scanString:@"," intoString:nil];
|
||||
}
|
||||
|
||||
// Trim '\0' from string end.
|
||||
NSUInteger index = string.length;
|
||||
unichar c;
|
||||
while (index > 0) {
|
||||
c = [string characterAtIndex:index - 1];
|
||||
if (c == '\0') {
|
||||
index--;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
value = [sc.string substringFromIndex:sc.scanLocation];
|
||||
NSRange range = NSMakeRange(sc.scanLocation, index - sc.scanLocation);
|
||||
value = [sc.string substringWithRange:range];
|
||||
if (value) {
|
||||
[valuesArray addObject:value];
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
|
||||
if (sampleBuffer->size > 1) {
|
||||
NSString *text = [[NSString alloc] initWithBytes:sampleBuffer->data
|
||||
length:sampleBuffer->size - 1
|
||||
length:sampleBuffer->size
|
||||
encoding:NSUTF8StringEncoding];
|
||||
|
||||
if (_converter && text.length) {
|
||||
|
||||
Reference in new issue
Block a user