Thanks for the answers.
I don't quite understand why using ASCII 32 (space) in
strings should cause any problem. Just to be sure I will
restrict myself to the range 32-126.
As for whether compression can be worth the trouble,
frankly I don't know, but I maintain that I'm able to
shrink approximately 60k into 20k of comressed data (plus
three lines added for the decompression code). As an
example here is the decompressor together with the
(compressed) description of the compression format used.
<html><head></head><body><script>
/* here is the uncompressing routine */
function u(s){var n,i=0,g=function(){if((n=s.charCodeAt(i++)-32)>=64)
n=(n-64)*95+s.charCodeAt(i++)-32;},o,d="",j=0;for(;;){g();d+=s.substr(i,
n);
i+=n;j+=n;g();if(0==(o=n))return d;g();while(n-- >0)d+=d.charAt(j++
-o);}}
/* and here is sample compressed data */
document.write(u([
"X<p>This is an example of compression for Javascript.
The@0#mat`d$(\nvery s",
"i`f$%, and5$'best de^$5bed by the algorithm N%)mented in=%#\nuna\")?ng
rout",
"ine:</p>\n\n<p>Conceptuall`n& P4Hg will read objects one at a time from
\n`",
"`$'\"input\"au&Ealways append data to a \"buffer\". Wheaj&#jobbE$!d`x$
az% ",
"D() containsa`/!e`q&!.b-)(Now here`g$ bz- bP(<blockquote><pre>forever
{\n ",
"b?&(<i>n</i>1$ av' 3(/ bytes verbatimbT& bS+% into1& az' `v,&offset`h%
7$'q",
"uit if:/$== 0aLK&copiedaJ& `i. @& aP'+current end`l$! fz$ ah, az2',
allowe=",
"$(overlappeQ%&egionsb#%' (i.e.a9/$<ag)%)\n}</cj$\"</c|+\"\n
dO%Lumbers ",
"smaller than 64 are encoded as ASCII /$% 32 +af%!n[%*. Bigger
\n0&!s[-!ugC%",
"3two printable ascii^'#s (c9% a!.1to \n126 included)ii& i]* i\\%-crude,
but",
" itc,&#s a<& b1% i<0 a $%. Notg_$ hZ$ c_< j 3\"onj (4 provides run
lengthbV",
"& `c$ kg$$freeh9*!Ol)$)urse, perb*%\"nchG% ff$(e poor wiJ$ a.$)ared
withff$",
"!llC)-ors\nlike gzipbZ&%honorcX% af-2atio can be achiev`q$ jJ( b5+ j$'
jC**",
"many repealf$*substringsb-& "].join("")));
</script></body></html>
regards,
Laurent Vogel
-- remove "ima" and "ictor" to get my email address
*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!