xmlnoob
11th July 2012 09:30 UTC
Replacing line with ${linefind}
i'm trying to replace some lines in the text file with linefind, i tried the combination of deleting lines then insert lines, using the examples listed in http://nsis.sourceforge.net/Docs/AppendixE.html#E.2.2 .
Inserting lines working fine, but delete lines always delete the first line of the file plus the line(s) i specified. Another serious issue when using linefind to delete lines is that it drop all the lines wchinese characters.
I'm using unicode nsis and the text file with chinese characters is encoded in utf-8.
So any thought of what i'm doing wrong?? The code i used was exactly the same as shown in the example except for the filenames & line numbers and of course the line i'm going to replace.
Thank you.
Afrow UK
11th July 2012 16:50 UTC
It may be easier to write your own function which enumerates file A while generating file B and then afterwards overwrites file A with file B. There are many functions on the Wiki which do this.
Stu
xmlnoob
12th July 2012 05:39 UTC
errr, ok. I try to find out other way to do it then.
xmlnoob
12th July 2012 07:17 UTC
also, any other precautions for messing with utf-8 + chinese characters?
i tried other functions found in google, but they all drop chinese characters and delete the first line of the file.
other than linefind, can i use filewrite + fileseek to delete a line from the file??
Afrow UK
12th July 2012 10:52 UTC
No as I said (but in a little greater detail):
Open your file A
Open new file B
For each line in A
Write to B unless line = line to delete
Close A
Close B
Delete B
Rename A -> B
Stu