EBCDIC to ASCII (Richard Gaskin)

Richard Gaskin ambassador at fourthworld.com
Thu Dec 29 09:40:20 EST 2016

Quentin Long wrote:

 > sez Richard Gaskin <ambassador at fourthworld.com>:
 >> Anyone here have a function to translate the old EBCDIC encoding
 >> format to anything more modern format like ASCII or UTF-8?
 > Doubtful. If ESR is right about its "at least six mutually
 > incompatible versions... and the absence of several ASCII punctuation
 > characters... (exactly which characters are absent varies according
 > to which version of EBCDIC you're looking at)", you'd pretty much
 > *have to* roll your own conversion function. The "six mutually
 > incompatible versions" thing strikes me as the most problematic,
 > but since the forum member who's asking for this seems to be working
 > with files from a single source, maybe it's safe to assume that all
 > the relevant files use the same version of EBCDIC?

It's a mess alright, but most interesting to me is what turned out to be 
the solution:

The OP in the forum thread that prompted my query noted that the FTP 
server he's using is just old enough that it includes an EBCDIC-to-ASCII 
algo built in, so that making the FTP request with "text" mode yields 
usable ASCII data.

The trick then became finding out how to specify "text" mode when using 
libURL, and the solution he found was quite simple once you learn enough 
about FTP to know how to do it:

By default FTP deliveres requested files without alteration, but 
apparently you can append the URL with ";TYPE=A" to tell the server to 
deliver the output as ASCII (similar in some respects to how HTTP allows 
arguments to be passed with GET as name-value pairs following a "?" 
after the URL).

His post about that is here:

Interestingly, he notes that this only works when using "get" with 
libURL, and not when using "put" - bug?

  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  Ambassador at FourthWorld.com                http://www.FourthWorld.com

More information about the use-livecode mailing list