// Exact copy of sun.print.PSPrinterJob.ascii85Encode([b)[b privatebyte[] ascii85Encode(byte[] inArr) { byte[] outArr = newbyte[((inArr.length+4) * 5 / 4) + 2]; long p1 = 85; long p2 = p1*p1; long p3 = p1*p2; long p4 = p1*p3; byte pling = '!';
int i = 0; int olen = 0; long val, rem;
while (i+3 < inArr.length) {
val = ((long)((inArr[i++]&0xff))<<24) +
((long)((inArr[i++]&0xff))<<16) +
((long)((inArr[i++]&0xff))<< 8) +
((long)(inArr[i++]&0xff)); if (val == 0) {
outArr[olen++] = 'z';
} else {
rem = val;
outArr[olen++] = (byte)(rem / p4 + pling); rem = rem % p4;
outArr[olen++] = (byte)(rem / p3 + pling); rem = rem % p3;
outArr[olen++] = (byte)(rem / p2 + pling); rem = rem % p2;
outArr[olen++] = (byte)(rem / p1 + pling); rem = rem % p1;
outArr[olen++] = (byte)(rem + pling);
}
} // input not a multiple of 4 bytes, write partial output. if (i < inArr.length) { int n = inArr.length - i; // n bytes remain to be written
val = 0; while (i < inArr.length) {
val = (val << 8) + (inArr[i++]&0xff);
}
int append = 4 - n; while (append-- > 0) {
val = val << 8;
} byte []c = newbyte[5];
rem = val;
c[0] = (byte)(rem / p4 + pling); rem = rem % p4;
c[1] = (byte)(rem / p3 + pling); rem = rem % p3;
c[2] = (byte)(rem / p2 + pling); rem = rem % p2;
c[3] = (byte)(rem / p1 + pling); rem = rem % p1;
c[4] = (byte)(rem + pling);
for (int b = 0; b < n+1 ; b++) {
outArr[olen++] = c[b];
}
}
/* The original intention was to insert a newline after every 78 bytes. *ThiswasmainlyintendedforlegibilitybutIdecidedagainstthis *partiallybecauseofthe(small)amountofextraspace,and *partiallybecauseforlinebreakseitherwouldhavetohardwire *ascii10(newline)orcalculatespaceinbytestoallocatefor *theplatform'snewlinebytesequence.Alsoneedtobecareful *aboutwhereitsinserted: *Ascii85decoderignoreswhitespaceexceptforonespecialcase: *youmustensureyoudonotsplittheEODmarkeracrosslines.
*/ byte[] retArr = newbyte[olen];
System.arraycopy(outArr, 0, retArr, 0, olen); return retArr;
}
publicstaticvoid main(String[] args) { new Test6732154().ascii85Encode(newbyte[0]);
System.out.println("Test passed.");
}
}
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.12Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.