Hi John,
There are always two text encodings involved.. The encoding of the
data in your program (normally some flavor of EBCDIC, but not always)
and the encoding of the data in the stream file (assuming you want to
open the file with Notepad, it should be some flavor of either ASCII or
Unicode.)
You mention 7F and 7C in code page 1026... which is a nice start. But,
you don't mention whether that's the file's code page or the program's
code page. Though, I'm guessing it's the program's code page, based on
the context.
CH5ASCII, as written, uses the default CCSID of the job to derive the
program's code page. It never attempts to specify the program's code
page, so if you've changed the code to specify 1026 instead of 819,
you've told it to translate from your job's EBCDIC data (within which,
7C/7F probably aren't the characters you expect) to Turkish EBCDIC in
the file (which is almost definitely not what you wanted -- and
certainly won't be readable in Notepad.)
Please also note that CH5ASCII was written for V4R5, and there have been
two enhancements to the IFS APIs since then that are useful to your
scenario:
1) With V5R1, the IFS supports CCSIDs, which are more powerful than (and
just as easy to use as) code pages. Simply use the O_CCSID flag instead
of the O_CODEPAGE one.
2) With V5R2, the open() API supports creating a file and performing
translation in a single call, with the O_TEXT_CREAT flag. This
simplifies your code. It also makes it possible to do auto-translation
on file systems that don't support setting a CCSID in the file header
(such as /QNTC).
While you might be able to make your program work without these two
enhancements, I heartily recommend using them. They just make life
easier, and your program more robust.
So please code something like this:
fd = open( '/whatever'
: O_CREAT + O_CCSID + O_TEXTDATA
+ O_TEXT_CREAT + O_WRONLY + O_INHERITMODE
: 0
: 1208
: 1026 );
data = x'7C7F';
callp write(fd: %addr(data): 2);
callp close(fd);
That assumes that you want the stream file to be CCSID 1208 (UTF-8). If
that's not correct, please choose the proper flavor of ASCII for Turkish
characters -- and make sure that you're running on a version of Windows
that supports the Turkish ASCII. (Unicode is so much simpler!)
You might also consider using Unicode on the RPG side as well... :-)
On 5/31/2012 11:19 AM, John Allen wrote:
I am attempting to write/create a txt file directly into the IFS the file contains Turkish characters
I have a copy of Scotts great and very helpful IFS eBook (Thank you very much Scott)
This file contains turkish characters such as ÜŞ
It appears using code 1026 these characters are Hex 7F and Hex 7C
For my test I did the following:
1) Modified Scotts program CH5ASCII that creates and writes some simple text to a text file
2) Changed the code that creates a new file to specify code page 1026 rather than 819
3) Output some text including a Hex 7F7C
Runs fine, but when the file is opened from the 400 (EDTF) I see a “@ I was expecting to see ÜŞ
When I open it with Notepad I see jibberish Ä…™@Ö¤¢‰•k%%É@“–¥…@£ˆ…@¦
Obviously there is something I am missing
Anybody know what I am doing wrong?
Thanks
John
_____
I am using the Free version of SPAMfighter<http://www.spamfighter.com/len> .
SPAMfighter has removed 3429 of my spam emails to date.
Do you have a slow PC?<http://www.spamfighter.com/SLOW-PCfighter?cid=sigen> Try free scan!
As an Amazon Associate we earn from qualifying purchases.