Subject: Re: Character conversion for sftp

Re: Character conversion for sftp

From: Fritz Elfert <>
Date: Tue, 30 Mar 2010 19:32:19 +0200

Hash: SHA1

Peter Stuge schrieb:
> Fritz Elfert wrote:
>> IMHO, the easiest way of porting to z/OS is to treat the whole source
>> code as ASCII and then use special ioctls (provided by IBM's libc) to
>> enable auto-conversion back to EBCDIC for stdin, stdout and stderr (if
>> those are connected to a terminal).
> Can we somehow make this easier by changing libssh2 or the build
> system?

I'm afraid there's no really simple solution - especially when dealing
with a library. At the moment, i don't have a z/OS system available. I
can start digging in some backups of old porting projects though ...
just give me some time ...

Here's what i remember right now:

1. There are #pragma directives for switching encoding of the compiler:

#pragma convert(819)
const char *str1 = "hello"; /* ASCII string const. */
#pragma convert(37)
const char *str1 = "hello"; /* EBCDIC string const. */

2. On the filesystem level, you can tag source files to be interpreted
as ASCII using the command

chtag -tc ISO8859-1 mysource.c

But then, you would need a special ASCII editor like viascii to edit them.

3. The stdio functions use EBCDIC by default, e.g: if fgets() stumbles
over an ASCII-'\n', it would *not* see an end-of-line.

4. There are ioctl's which can switch a file descriptor into
auto-convert mode (sorry - can't remember the exact names/syntax).

Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla -

Received on 2010-03-30