I was having some problems too but had no idea why.
Then i saw this post and yes, there's something still wrong.
In my case when I simply have this piece of text on a file which is being read
Code: Select all
http://willterrell.com/wp-content/uploads/2011/11/flying_squirrels_willterrell.jpg
if use a
readfile with parameters i can't get the text displayed, showing only '' as a preview (see code below).
Sometimes if I append text to the wrongly previewed file, the appended section gets corrupted like this:
Code: Select all
㸾㸾㸾㸾㸾㸾㸾㸾㸾㸾㸾㸾㸾㸾㸾㸾㸾㸾㸾㸾ാഊ∊湉吠楨楒敶≲椠潳杮戠⁹流牥捩湡栠慥祶洠瑥污戠湡求捡慌敢潓楣瑥ⱹ映慥畴敲湯琠敨物㈠〰‵楳瑸瑳摵潩愠扬浵䴠晡
Cool: when I paste the snippet the '[/code]' section has turned '[edoc/]', and selecting the piece itself was hard. Maybe this gives a hint on codepage identification?
And this is a code I'm using which gives me no errors at all when target document is an ANSI code-based or gives me trouble with all unicode-based plus the 1st situation I described:
Code: Select all
end(getinfo("CountSelected") < 1), "Pick a file first!";
end(getinfo("CountSelected") > 1), "Only one!!";
end(compare("<xyver>", '10.90.0100', 'v') < 0, "Run this @ v10.90.0100+.");
$append = "<clipboard>";
$sep = ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
$offset = "100"; // amount to be read up to the end of the file
$file = "<curitem>";
$fsize = filesize("$file");
//readfile(filename, [mode], [numbytes], [codepage], [start=1])
$calcoffset = $fsize - $offset;
$initial = readfile("$file", , , , $calcoffset);
text "------------------Ending of current file (last $offset chars):<crlf>________________________________________________________<crlf>'$initial'<crlf>___________________\\\\\\\\\\\\|||////////////___________________<crlf 2>Current separator: '$sep'<crlf 2>------------------Text to be appended:<crlf>_____________________________________<crlf 2>'$append'", , , "Preview:" , w;
$answer = confirm("Continue?<crlf 2>Previous window was a preview of what will be appended...")?"_Y":"_N";
if ($answer == "_N") { end 1, "User has Canceled!"; }
elseif ($answer == "_Y") { }
$sep2 = formatlist("$sep", v, "");
writefile("$file", "<crlf 2>$sep<crlf 2>$append<crlf 2>$sep2", a);
$fsize = filesize("$file");
$calcoffset = $fsize - $offset;
$final = readfile("$file", , , , $calcoffset);
text "------------------Initial ending (last $offset chars):<crlf 2>'$initial'<crlf 2>------------------Appended (cropped, last $offset chars):<crlf 2>'$final'", , , , w;