protected function CsvParser::trimNewline in Feeds 8.3
Removes the trailing line ending.
This does not call trim() since we only want to remove the last line ending, not all line endings.
Parameters
string $last_character: The last character.
string $field: The current field.
Return value
string The field with the line ending removed.
1 call to CsvParser::trimNewline()
- CsvParser::parseLine in src/
Component/ CsvParser.php - Parses a single CSV line.
File
- src/
Component/ CsvParser.php, line 354
Class
- CsvParser
- Parses an RFC 4180 style CSV file.
Namespace
Drupal\feeds\ComponentCode
protected function trimNewline($last_character, $field) {
// Windows line ending.
if ($last_character === "\n" && substr($field, -1) === "\r") {
return substr($field, 0, -1);
}
// Unix or Mac line ending.
if ($last_character === "\n" || $last_character === "\r") {
return $field;
}
// Line ended without a trailing newline.
return $field . $last_character;
}