× 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.



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.

This thread ...

Follow-Ups:
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.