TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Neil Heller
from: Jasen Betts
date: 2003-03-28 21:22:24
subject: portability

Hi Neil.

27-Mar-03 08:31:00, Neil Heller wrote to Jasen Betts


 NH>> It just dawned on me (after reading Mr. McBrine's post) that if
 NH>> one were to use only decimal numerics and English alphas
 NH>> converting from ASCII to EBCIDIC or vice versa would be really
 NH>> quick (as in table driven, no decisions).

 JB>> yeah,  something like

 JB>> *(char_pointeer++) =
 JB>> "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"[digit]

 NH> That's interesting.  Would you please write a snippet in which you
 NH> would use the above pointer to convert ASCII to EBCDIC, or vice
 NH> versa?

that was intended as a replacment for whatever variation on

   *(charpointer++)=digit+( digit<10 ?'0':'A'-10)

was commented on recently, and AFAICT which works for hexadecimal in ASCII
and EDCDIC but not for base-36 in EBCDIC (or any base above 20)

 JB>> would compile and work fine on both EBCDIC and ASCII/UTF systems.
 JB>> also it could possibly be extended for base64 encoding etc...

 NH> Are you talking about conversion to/from unicode here?

no, just saying that the code would work in that environment too.

 NH> What I had imagined doing was setting up a 16x16 matrix and then
 NH> using the source character value as an offset into that table.

16x16 = 256  yeah that'd be how I'd do the symbol-set conversion too.

 I's immagine two 256 byte long tables one to convert each way.
the second ttable could be derived from the first or specified
explitly.

 -=> Bye <=-

---
* Origin: Black Holes were created when God divided by zero! (3:640/1042)
SEEN-BY: 633/267 270
@PATH: 640/1042 531 954 774/605 123/500 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.