Hi,
I have to separate a character string line by line (to process them individually afterwards):
/*
* My name
*/
#include <asf.h>
#include "language.h"
//defaut
static const char lg_clic1sec_cancel_fr[] = {"Clic 1sec:\nAnnule"};
static const char lg_clic1sec_cancel_en[] = {"Click 1sec:\nCancel"};
const char * lg_clic1sec_cancel[] = {lg_clic1sec_cancel_fr, lg_clic1sec_cancel_en};
. I use file.split('\n')
The problem is that in my character string there is written \n
in all letters, suddenly the file.split
cuts the text at this place!
[{"id":"2b8e344e06f27e38","type":"function","z":"378c07b4.3c0cd8","name":"test","func":"const file = \n\n`\n/*\n* My name\n*/\n\n#include <asf.h>\n\n#include \"language.h\"\n\n//defaut\nstatic const char lg_clic1sec_cancel_fr[] = {\"Clic 1sec:\\nAnnule\"};\nstatic const char lg_clic1sec_cancel_en[] = {\"Click 1sec:\\nCancel\"};\nconst char * lg_clic1sec_cancel[] = {lg_clic1sec_cancel_fr, lg_clic1sec_cancel_en};\t\n\n`\n\nlet lines = file.split('\\n')\n\nnode.warn(lines)//affiche lignes par ligne originales\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2370,"y":780,"wires":[["91883f67f4e39991"]]},{"id":"fb99e1973b640a89","type":"inject","z":"378c07b4.3c0cd8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":2220,"y":780,"wires":[["2b8e344e06f27e38"]]}]
How can I tell the difference between a line break and a written \n
?
or how to separate each line without taking into account \n
?
Thanks