🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.postscript.programming
Article #268

Re: ASCII-85 Encoding per PS 3rd ED Spec

#268
From: Alex_Cherepanov
Date: Sun, 08 Oct 2006 02:13
39 lines
2258 bytes
Outtascope@adobeforums.com wrote:

> For instance, consider an input file consisting of a single digit: "."
> The ascii value for . (period) is 46. Our resulting 4-tupple of 46,0,0,0
 > According to the spec this would be output simply as /c followed by ~>
This is correct.

> Subsequent decoding of this, however, gives us a value of 45. 
The spec declares that the information is sufficient for deciding
but leaves development of the decoding algorithm to the exercise
of the reader. For instance, Ghostscript uses the following
procedure to decode the remaining bytes.

int a85d_finish(int ccount, ulong word, stream_cursor_write * pw)
{  /* Assume there is enough room in the output buffer! */
    byte *q = pw->ptr;
    int status = EOFC;
    switch (ccount) {
         case 0:
             break;
         case 1:         /* syntax error */
             status = ERRC;
             break;
         case 2:         /* 1 odd byte */
             word = word * (85L * 85 * 85) + 85L * 85 * 85 - 1L;
             goto o1;
         case 3:         /* 2 odd bytes */
             word = word * (85L * 85) + 85L * 85L - 1L;
             goto o2;
         case 4:         /* 3 odd bytes */
             word = word * 85L + 84L;
             q[3] = (byte) (word >> 8);
o2:         q[2] = (byte) (word >> 16);
o1:         q[1] = (byte) (word >> 24);
             q += ccount - 1;
             pw->ptr = q;
     }
     return status;
}
Technical Details
Message-ID: <4FA3E03966D24DAE3A1C81296238BFE1@in.webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news3.google.com!news2.volia.net!news.musoftware.de!newsfeed.x-privat.org!spool.x-privat.org!webcrossing
References: <3bc1deaa.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10c61a,1eae8f07fad75f86
X-Google-Attributes: gid10c61a,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: Alex_Cherepanov@adobeforums.com
Newsgroups: adobe.postscript.programming
Subject: Re: ASCII-85 Encoding per PS 3rd ED Spec
Message-ID: <4FA3E03966D24DAE3A1C81296238BFE1@in.webcrossing.la2eafNXanI>
Date: Sat, 7 Oct 2006 19:13:32 -0700
References: <3bc1deaa.-1@webcrossing.la2eafNXanI>
Lines: 42
User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.7.1) Gecko/20040707
X-Accept-Language: en-us, en
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!news3.google.com!news2.volia.net!news.musoftware.de!newsfeed.x-privat.org!spool.x-privat.org!webcrossing