Merge pull request #377 from hmarr/support-cr-eols

Handle carriage-return-only newlines
This commit is contained in:
Tankred Hase 2016-02-14 23:03:21 +07:00
commit e562a33c91

View File

@ -48,7 +48,7 @@ export default function Literal() {
*/ */
Literal.prototype.setText = function(text) { Literal.prototype.setText = function(text) {
// normalize EOL to \r\n // normalize EOL to \r\n
text = text.replace(/\r/g, '').replace(/\n/g, '\r\n'); text = text.replace(/\r\n/g, '\n').replace(/\r/g, '\n').replace(/\n/g, '\r\n');
// encode UTF8 // encode UTF8
this.data = this.format === 'utf8' ? util.str2Uint8Array(util.encode_utf8(text)) : util.str2Uint8Array(text); this.data = this.format === 'utf8' ? util.str2Uint8Array(util.encode_utf8(text)) : util.str2Uint8Array(text);
}; };