× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



You are coding it correctly, and as far as I can tell, it's working correctly.

I think you're getting confused because DSPF translates the data to EBCDIC before displaying it to you. It sees the file is CCSID 1200 and runs it through a 1200 -> jobccsid (or job default ccsid) before displaying it.

One tell-tale sign is to use WRKLNK on the file and take option 5. Page down to the "Size of object data in bytes" value. Does it say 14? Then it's EBCDIC (Hello World! + CRLF is 14 bytes long) or does it say 28? If it's 28, then it's converted to a double-byte CCSID like UCS2.

If WRKLNK shows 28 bytes, and DSPF only shows 14, then clearly DSPF is translating the data before displaying it.

Try using QShell, such as:

QSH CMD('od -x /tmp/test.txt')

This should show the hex data, and it should show UCS2. Another way to see it is to transfer it using a binary-safe file transfer (the most obvious one would be FTP in binary mode) to your PC. Remember, your PC doesn't understand EBCDIC... can you display it?


sjl wrote:
*** I'm stumped. I found this article and example code by Scott K. It looked very simple, even for an idiot like me: <http://systeminetwork.com/article/convert-data-ucs2-or-utf-16>
H DFTACTGRP(*NO)
/copy ifsebook/qrpglesrc,ifsio_h
D fd s 10I 0
D data s 1000C ccsid(1200)
/free
unlink('/tmp/test.txt');
fd = open('/tmp/test.txt'
: O_CREAT + O_TRUNC + O_CCSID + O_WRONLY
: S_IWUSR+S_IRUSR
: 1200 );
if (fd < 0);
// handle error
endif;
data = %ucs2('Hello World!' + x'0d25');
callp write(fd: %addr(data): %len(%trimr(data))*2);
callp close(Fd);
*inlr = *on;
/end-free

*** So I copied the source to my system, compiled it, and ran it. The file /tmp/test.txt was correctly created as CCSID(1200):
Display Attributes Object . . . . . . : /tmp/test.txt Type . . . . . . . . . . . . . . . . . : STMF Owner . . . . . . . . . . . . . . . . : US0T1106 System object is on . . . . . . . . . : Local Auxiliary storage pool . . . . . . . . : 1 Object overflowed . . . . . . . . . : No Coded character set ID . . . . . . . . : 1200 Hidden file . . . . . . . . . . . . . : No PC system file . . . . . . . . . . . . : No Read only . . . . . . . . . . . . . . : No Need to archive (PC) . . . . . . . . . : Yes Need to archive (System) . . . . . . . : Yes *** but the data in the file (Hello World!') is still in EBCDIC:
Browse : /tmp/test.txt Record : 1 of 1 by 14 Column : 1 59 by 19 Control : - - - - + - - - - * - - - - + - - - - * ----+----*----+----* 405C5C5C 5C5C5C5C 5C5C5C5C 5CC28587 89959589 ************Beginni C8859393 9640E696 9993845A 0D25 Hello World! 405C5C5C 5C5C5C5C 5C5C5C5C 5CC59584 40968640 ************End of *** what am I doing wrong?
- sjl


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.