🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #9544

write/writeln fails for some strings

#9544
From: thechrisproject
Date: Thu, 17 Aug 2006 14:18
21 lines
4573 bytes
I have a string which is a giant chunk of xml that represents the contents of an .inx file. I need to make a new file and write this string to it. My first guess was to just make a new file, and use a single write statement, like this:

var newFile = File("~/Documents/newFile.inx");
newFile.open("w");
newFile.write(xmlText);
newFile.close();

This fails. The write command returns false. I then tried doing it line by line:

var newFile = File("~/Documents/newFile.inx");
newFile.open("w");
var xmlLines = xmlText.split('\n');
for(var i = 0; i < xmlLines.length; i++) { 	success = newFile.write(xmlLines[i]); 	if(!success) $.writeln('failed to write line: ' + xmlLines[i]); } newInxFile.close();

Out of the hundreds of lines, only five fail. It is always the same five. Here's the output:

failed to write line: 		<cfen pnam="k_Kana" font="c_Kozuka Mincho Pro" ptfs="k_R" jcfs="D_100" bshf="D_0" phzs="D_100" pvts="D_100" jcfc="k_&#12353;&#12354;&#12355;&#12356;&#12357;&#12358;&#12359;&#12360;&#12361;&#12362;&#12363;&#12364;&#12365;&#12366;&#12367;&#12368;&#12369;&#12370;&#12371;&#12372;&#12373;&#12374;&#12375;&#12376;&#12377;&#12378;&#12379;&#12380;&#12381;&#12382;&#12383;&#12384;&#12385;&#12386;&#12387;&#12388;&#12389;&#12390;&#12391;&#12392;&#12393;&#12394;&#12395;&#12396;&#12397;&#12398;&#12399;&#12400;&#12401;&#12402;&#12403;&#12404;&#12405;&#12406;&#12407;&#12408;&#12409;&#12410;&#12411;&#12412;&#12413;&#12414;&#12415;&#12416;&#12417;&#12418;&#12419;&#12420;&#12421;&#12422;&#12423;&#12424;&#12425;&#12426;&#12427;&#12428;&#12429;&#12430;&#12431;&#12432;&#12433;&#12434;&#12435;&#12436;&#12437;&#12438;&#12445;&#12446;&#12449;&#12450;&#12451;&#12452;&#12453;&#12454;&#12455;&#12456;&#12457;&#12458;&#12459;&#12460;&#12461;&#12462;&#12463;&#12464;&#12465;&#12466;&#12467;&#12468;&#12469;&#12470;&#12471;&#12472;&#12473;&#12474;&#12475;&#12476;&#12477;&#12478;&#12479;&#12480;&#12481;&#12482;&#12483;&#12484;&#12485;&#12486;&#12487;&#12488;&#12489;&#12490;&#12491;&#12492;&#12493;&#12494;&#12495;&#12496;&#12497;&#12498;&#12499;&#12500;&#12501;&#12502;&#12503;&#12504;&#12505;&#12506;&#12507;&#12508;&#12509;&#12510;&#12511;&#12512;&#12513;&#12514;&#12515;&#12516;&#12517;&#12518;&#12519;&#12520;&#12521;&#12522;&#12523;&#12524;&#12525;&#12526;&#12527;&#12528;&#12529;&#12530;&#12531;&#12532;&#12533;&#12534;&#12535;&#12536;&#12537;&#12538;&#12540;&#12541;&#12542;" plck="b_t" jcfa="b_t" ptag="x_0" Self="rc_u77"/>

failed to write line: 		<cfen pnam="k_Punctuation" font="c_Kozuka Mincho Pro" ptfs="k_R" jcfs="D_100" bshf="D_0" phzs="D_100" pvts="D_100" jcfc="k_�&#8213;&#8214;����&#8229;�&#8242;&#8243;&#8741;&#12289;&#12290;&#12296;&#12297;&#12298;&#12299;&#12300;&#12301;&#12302;&#12303;&#12304;&#12305;&#12308;&#12309;&#12316;&#12539;&#65281;&#65288;&#65289;&#65292;&#65294;&#65295;&#65306;&#65307;&#65311;&#65339;&#65341;&#65371;&#65373;&#65374;" plck="b_t" jcfa="b_t" ptag="x_0" Self="rc_u78"/>

failed to write line: 		<cfen pnam="k_Symbols" font="c_Kozuka Mincho Pro" ptfs="k_R" jcfs="D_100" bshf="D_0" phzs="D_100" pvts="D_100" jcfc="k_�����������&#913;&#914;&#915;&#916;&#917;&#918;&#919;&#920;&#921;&#922;&#923;&#924;&#925;&#926;&#927;&#928;&#929;&#931;&#932;&#933;&#934;&#935;&#936;&#937;&#945;&#946;&#947;&#948;&#949;&#950;&#951;&#952;&#953;&#954;&#955;&#956;&#957;&#958;&#959;&#960;&#961;&#963;&#964;&#965;&#966;&#967;&#968;&#969;&#1025;&#1040;&#1041;&#1042;&#1043;&#1044;&#1045;&#1046;&#1047;&#1048;&#1049;&#1050;&#1051;&#1052;&#1053;&#1054;&#1055;&#1056;&#1057;&#1058;&#1059;&#1060;&#1061;&#1062;&#1063;&#1064;&#1065;&#1066;&#1067;&#1068;&#1069;&#1070;&#1071;&#1072;&#1073;&#1074;&#1075;&#1076;&#1077;&#1078;&#1079;&#1080;&#1081;&#1082;&#1083;&#1084;&#1085;&#1086;&#1087;&#1088;&#1089;&#1090;&#1091;&#1092;&#1093;&#1094;&#1095;&#1096;&#1097;&#1098;&#1099;&#1100;&#1101;&#1102;&#1103;&#1105;&#8208;���&#8251;&#8451;&#8491;&#8592;&#8593;&#8594;&#8595;&#8658;&#8660;&#8704;&#8706;&#8707;&#8711;&#8712;&#8715;&#8722;&#8730;&#8733;&#8734;
Technical Details
Message-ID: <3bc14b95.-1@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news2.volia.net!news.ecp.fr!news.stben.net!webcrossing

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,79c571a773294c0e,start
X-Google-Attributes: gidf939a,public
X-Google-Language: ENGLISH,ASCII
From: thechrisproject@adobeforums.com
Newsgroups: adobe.scripting.indesign
Subject: write/writeln fails for some strings
Message-ID: <3bc14b95.-1@webcrossing.la2eafNXanI>
Date: Thu, 17 Aug 2006 07:18:26 -0700
Lines: 73
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news2.volia.net!news.ecp.fr!news.stben.net!webcrossing