In my own experience, I do not have to reopen the file. If you are going
to write text data, it's enough with the O_TEXTDATA flag. But the
requirement is to write from a buffer that has already UTF-8 data (some
sort of another trick may be done, though). It's easier to just declare a
UTF-8 (CCSID 1208) variable as the source buffer to write to the file.

In very rare cases did I have to reopen the file when I first opened it
with the open() API but then you may want to write to it as a buffered file
and reopen it with fopen(). Those are the cases that I can recall, but no,
you don't have to do that if you create it (or append data later) with
open(). Just make sure your data has valid UTF-8 data. Remember that
UTF-8 became a superset of the original ASCII character set, in the case of
English, all code points are just the same as ASCII up to character 127.
UTF-8 is used with romantic languages (Spanish, Frech, Portuguese) that
have accented characters, tilde characters and diaeresis characters and all
European characters, and of course any other Unicode characters that may
fit the UTF-8 specification. Starting code point 192, UTF-8 takes a
two-byte (even three-byte) code point for all those characters described
above, and this also has been somewhat confusing for some devs.

When you inspect such a file binary-wise, you may see that, for example,
the place where, say, character Á is, you will actually see in hex C3 81
and not just C1 as you would see if it was coded as code page 1252
(Windows).

UTF-16 is for more sophisticated languages, especially Asian ones, but for
your application, UTF-8 is good.

Finally, if you are going to reuse the file and append data to it, open it
without the O_CREAT flag, but rather use the O_APPEND instead and you'll
get it.

Try it out!

HTH

JS

El mar, 2 dic 2025 a las 9:13, cesco via MIDRANGE-L (<
midrange-l@xxxxxxxxxxxxxxxxxx>) escribió:

Do you need to reopen it?Try to remove O_TEXTDATA , probably it triggers
some sort of auto conversion hitting maybe some problem in such very old
release.Or do all normally in RPG, and then try to use some command like
CPY ? It should have CCSID from-to.


On Tuesday, December 2, 2025 at 04:00:48 PM GMT+1,
konsult@xxxxxxxxxxxxxxx <konsult@xxxxxxxxxxxxxxx> wrote:

I need to create a file in the IFS and the file HAS to be encoded in UTF-8
(CCSID 1208).

The machine is unfortunately running on V7R1 and that is due to a software
package that cannot (as I am told be migrated to more current releases). So
writing with SQL is out of the equation, sadly.



I have tested a function based on Scott Klements writings and while it
works
with conversion to ASCII it fails when I change to CCSID 1208.



As per the example the IFS file is first created with 1208 as the CCSID.
This works and is coded thus:



c eval fd = open('/home/ao/ch5_file3.txt':

c O_CREAT+O_WRONLY+O_CCSID:

c S_IWUSR+S_IRUSR+S_IRGRP+S_IROTH:

c 1208)



But when the file is closed an reopened this open gets an error:



c eval fd = open('/home/ao/ch5_file3.txt':

c O_WRONLY+O_TEXTDATA)



I receive an "open() conversion error"



Any suggestions? I assume that I need some other parameters for the second
open when using UTF-8 but I have as yet not found which one to use or
possibly omit.











--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.


--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.



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