|
Thanks Larry! Makes perfect sense - I knew I was close, but I just couldn't see the answer. I fixed my program and it works! Carmen -----Original Message----- date: Tue, 27 Jul 2004 09:35:52 +0100 from: "Larry Ducie" <larry_ducie@xxxxxxxxxxx> subject: RE: UTF-8 conversion Carmen, >>/free myfile = >>'/attachment/UTF-8.txt'; openflags = O_RDONLY + >>O_TEXTDATA; mode = S_IRUSR + S_IRGRP + S_IROTH; >> CCSID_UTF8 = 1208; >> fd = open( myfile : >>openflags : mode >> : CCSID_UTF8 ); Be sure that you are specifying CCSID with the flag CCSID_UTF8, and not codepage. This is done in the openflags - O_CODEPAGE has the value 8388608, and O_CCSID has the value 32. Including O_CCSID in the openflags tells the API that you are specifying the fourth parameter as a CCSID value and not a CODEPAGE value. When you create a file this CCSID value is assigned to the file (not necessarily the data) This is known as the File CCSID. For any subsequent open of the file, the fouth parameter specifies the CCSID that you want to convert to/from. This is known as the open CCSID - the special value of 0 (zero) will default the open CCSID to the job CCSID. This is what you want to set for reading your file. The data will then be converted from the File CCSID to the open CCSID. That is, from CCSID 1208 to your job CCSID. To create the file as UTF-8 you should have something like: D O_CCSID C Const(32) /free myfile = '/attachment/UTF-8.txt'; openflags = O_CREATE + O_WRTONLY + O_TRUNCATE + O_CCSID; mode = S_IRWXU + S_READWRITE; CCSID_UTF8 = 1208; fd = open( myfile : openflags : mode : CCSID_UTF8); To open a file created as UTF-8 you need to specify something like: /free myfile = '/attachment/UTF-8.txt'; openflags = O_RDONLY + O_TEXTDATA + O_CCSID; mode = S_IRUSR + S_IRGRP + S_IROTH; fd = open( myfile : openflags : mode :0); As you can see, you have specified the "Open" CCSID as the job CCSID. This will ensure that any read/writes will convert the data to/from your job CCSID and File CCSID respectively. I hope this makes sense. Cheers Larry Ducie
As an Amazon Associate we earn from qualifying purchases.
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.