From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,bffcdbd805329ff8 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-29 09:33:42 PST Path: archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!cpk-news-hub1.bbnplanet.com!nycmny1-snh1.gtei.net!news.gtei.net!newsfeed.mathworks.com!newsxfer.eecs.umich.edu!cyclone.rdc-detw.rr.com!news.mw.mediaone.net!lsnws01.we.mediaone.net!typhoon.san.rr.com.POSTED!not-for-mail Message-ID: <3B8D181E.8C9523D@san.rr.com> From: Darren New Organization: Boxes! X-Mailer: Mozilla 4.77 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Ada and Internet stuff References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Wed, 29 Aug 2001 16:28:13 GMT NNTP-Posting-Host: 24.165.20.229 X-Complaints-To: abuse@rr.com X-Trace: typhoon.san.rr.com 999102493 24.165.20.229 (Wed, 29 Aug 2001 09:28:13 PDT) NNTP-Posting-Date: Wed, 29 Aug 2001 09:28:13 PDT Xref: archiver1.google.com comp.lang.ada:12559 Date: 2001-08-29T16:28:13+00:00 List-Id: > David has posted base64 encode/decode source code at > www.adapower.com/alg/base64.html > (That was pretty fast, eh? :) Cool! I definitely want to read this a few times and learn more Ada. :-) Thanks! (My primary goal in writing the base64 stuff was practicing simple Ada stuff.) I'm wondering something. Do people generally treat Ada.Streams.Stream_Element_Array as the equivalent of an array of octets without further checking? Also, what's the mechanism for dealing with things like UTF-8? I.e., I'm assuming that Wide_String is a string of UTF or other non-ASCII characters. Does one simply read a file with the wide character reading routines and assume that the runtime will do the right translations? E.g., how would one properly read an XML (default of UTF-8 encoding) file? As for the base64 stuff, I'd suggest the following additions: -- Target'length must be at least: -- Output_Quad_Count: constant := (Source'length + 2) / 3; -- Output_Byte_Count: constant := 4 * Output_Quad_Count; -- Target'length = Output_Byte_Count + 2 * (Output_Byte_Count / 76) This should be a function. :-) Probably, it would be best to have a function that takes an input length and returns the output length in both directions, so you can allocate your buffers properly before calling the functions. Also, a function where you can say "tell me how many characters of base64 text I should pass in to get as close to N octets back" and "how many octets will give me just under N characters back" would be useful. I.e., if I have a file that I'm outputting the big base64-encoded file out to, how much text do I read and pass to the decoder in one chunk, and in the other direction, if I have String(1..100_000) to encode into, how many bytes of raw data is that? I'd be happy to tackle this. :-) -- Darren New San Diego, CA, USA (PST). Cryptokeys on demand.