1.2k questions

1.4k answers

361 comments

339 users

Categories

Sidebar
+1 vote
731 views
by matt-w-2627 (3.2k points)
How can I be sure that QIE will handle the endofline / newline / carriage return within the text file I am processing into an Array, regardless of source system (Unix, vs Windows, etc)?

1 Answer

+1 vote
 
Best answer

when processing the text file, it is best to use a regular expression to handle the line encoding.

reference for regular expressions in javascript: http://www.javascripter.net/faq/regularexpressionsyntax.htm

for example:

var SourceArray = source.getNode('/').split("\\r?\\n|\\r");

the above code will handle situations where the carriage return is present along with the newline, if newline is by itself, or if the carriage return is by itself.

Historically, MacOS's line encoding is \r, Windows is \r\n and Unix is \n

You can test the use cases by changing the line encoding in your sample messages,

Hex 0A = Newline (\n)
Hex 0D = Carriage Return (\r)

by matt-w-2627 (3.2k points)
edited by matt-w-2627
...