I'm trying to decode an ASCII85 (or Base 85) string using ascii85 unit, but an EReadError exception is raised with the message "could not seek...".Since ascii85 unit doesn't have an easy Encode/Decode function, I did one based in "base64.DecodeStringBase64();".The code is:

I'm trying to decode an ASCII85 (or Base 85) string using ascii85 unit, but an EReadError exception is raised with the message "could not seek...".

This is most likely because you call Decoder.Size.

The TASCII85DecoderStream class does not override the Size implementation, so the default implementation of TStream.GetSize is used. And TStream.GetSize uses seeking. But, the TASCII85DecoderStream.Seek does not allow seeking (raising the EReadError you see, in most non-trivial cases).

You can verify this by looking at TASCII85DecoderStream implementation (in packages/fcl-base/src/ascii85.pp in FPC sources) and TStream implementation (in rtl/objpas/classes/streams.inc in FPC sources).

You most probably (but I have not tried it, so don't hold me to it) solve it by passing 0 instead of Decoder.Size to CopyFrom. The CopyFrom may work then OK. In general, it's not guaranteed that the CopyFrom will work, it's even documented: "Note that this cannot be used with streams that do not allow seeking or do not allow determining the size of the stream.". But, at least looking at the CopyFrom implementation in current FPC 3.1.1, it may actually work in this simple case.

If this doesn't help, you will need to implement your own version of "CopyFrom" that works on a non-seekable stream like TASCII85DecoderStream. It's not very difficult, you can take a look at what the TStream.CopyFrom is doing in FPC sources (rtl/objpas/classes/streams.inc)