RE: P.P.S.: Re: Issues with code page conversion..grateful for any help

<[email protected]> Tue, 31 Mar 2026 17:31:22 +0200
Newsgroups gmane.comp.lang.as400.rpg
Message-ID <[email protected]>
Hi Britta,

If I look into my file with DSPPFM and use F10 to display contents in Hex I get "ł" showing as x'9A'.

I used the following to replace x'9A' with UniCode x'C582'...

I thought this would solve the problem but now my text shows as <Name>Zakªad </Name>  in my xml output

The output file was created with CCSId 1208

Any idea what I am doing wrong ?

Mit freundlichen Grüßen / Kind regards / Bien à vous,
 
Seán Courtney – 0172-8560663
 
Zunächst geplante Abwesenheiten
 ____
Eiresoft Software Solutions

 
 
 

-----Original Message-----
From: RPG400-L <[email protected]> On Behalf Of Birgitta Hauser
Sent: Tuesday, 31 March 2026 16:34
To: 'RPG programming on IBM i' <[email protected]>; 'Daniel Gross' <[email protected]>
Subject: RE: P.P.S.: Re: Issues with code page conversion..grateful for any help

Hi Sean,

Have you checked the Hex-Values?
From What CCSID are you converting?
If the base is CCSID 273 the ł is not in the character set. Instead of the ł a substitution character would have been used.
... and a substitution will not return a good value.

Try to run the following SQL Statement:
Values(Cast('Zakład' as VarChar(50) CCSID 1208), Cast('Zakład' as VarChar(50) CCSID 273), Cast('Zakład' as VarChar(50) CCSID 870)); If you run it in ACS, you'll see a substitution character in the 2nd Column (German), in the other columns the ł is displayed correctly.

The following SQL Statement generates the Hex values for the previous SQL Statement:
Values(Hex(Cast('Zakład' as VarChar(50) CCSID 1208)), Hex(Cast('Zakład' as VarChar(50) CCSID 273)), Hex(Cast('Zakład' as VarChar(50) CCSID 870)));

The result is:  
5A616BC5826164 (UTF-8)
E981923F8184 CCSID 273  (x'EF' is the substitution character ... which will be used for all characters that are not in the appropriate character set)
E981929A8184 CCSID 870


Mit freundlichen Grüßen / Best regards

Birgitta Hauser
Modernization – Education – Consulting on IBM i Database and Software Architect IBM Champion since 2020

"Shoot for the moon, even if you miss, you'll land among the stars." (Les Brown) "If you think education is expensive, try ignorance." (Derek Bok) "What is worse than training your staff and losing them? Not training them and keeping them!"
"Train people well enough so they can leave, treat them well enough so they don't want to. " (Richard Branson) "Learning is experience … everything else is only information!" (Albert Einstein)


-----Original Message-----
From: RPG400-L <[email protected]> On Behalf Of [email protected]
Sent: Tuesday, 31 March 2026 15:24
To: 'Daniel Gross' <[email protected]>; [email protected]
Subject: RE: P.P.S.: Re: Issues with code page conversion..grateful for any help

Hi Daniel,

The polish alphabet hast the following special characters : ą, ć, ę, ł, ń, ó, ś, ź, ż

The fourth character should be : Ł, ł (L with stroke): Sounds like English 'w' (like w in "water").

In my example I want Zakªad to output to Zakład

--
I create my outfile with :
exec sql                         
CALL QSYS2.IFS_WRITE(            
PATH_NAME => trim(:Path),        
LINE => '',                      
END_OF_LINE => 'NONE',           
FILE_CCSID => 1208,      
OVERWRITE => 'REPLACE')          

And I write to it with 

exec sql                     
CALL QSYS2.IFS_WRITE(        
PATH_NAME   => trim(:Path),  
LINE        => trim(:data),  
OVERWRITE   => 'APPEND',     
END_OF_LINE => 'CRLF');      

Where Data is defined as 

dcl-s Data varchar(1000) ccsid(1208);

Mit freundlichen Grüßen / Kind regards / Bien à vous,
 
Seán 
 
 

-----Original Message-----
From: Daniel Gross <[email protected]>
Sent: Tuesday, 31 March 2026 15:08
To: [email protected]
Cc: [email protected]
Subject: P.P.S.: Re: Issues with code page conversion..grateful for any help

P.P.S.:

What do you expect the UTF-8 value to be? You know, that CCSIDs 870 and 273 are EBCDIC CCSIDs - and UTF-8 is Unicode - and it's loosely based on ASCII.

So if you look at a UTF-8 file in raw format from IBM i side, it should look like "garbage" - But if you read it again (like with IFS_READ) you should see the correct values.

Also - have you checked the CCSID of the IFS file? If the file already exists, the IFS_WRITE_UTF8 doesn't change it, but it write out UTF-8. If you read the file again, the CCSID has to be UTF-8, because it can only find out should coding to use, if the files CCSID is correctly set.

These are just some thoughts.

HTH
Daniel


> Am 31.03.2026 um 14:49 schrieb Daniel Gross <[email protected]>:
> 
> Hi Sean,
> 
> is the original data in the correct CCSID?
> 
> I would give it a try
> 
>   dcl-s origVal varchar(100) ccsid(870) inz('Zakład');
>   dcl-s utf8Val varchar(100) ccsid(*utf8) inz;
> 
>   utf8Val = origVal;
>   origVal = utf8Val;
> 
> And debug this step by step. What is in those 2 strings? Are the values correct?
> 
> In the next step, try to write origVal to a test-file with IFS_WRITE_UTF8 - and compare.
> 
> If the CCSIDs are correct, you shouldn't have problems with UTF8 and other CCSIDs.
> 
> HTH
> Daniel
> 
> P.S.: can you post the hex values of the original value (in CCSID 870) and the UTF8 value please?
> 
> 
>> Am 31.03.2026 um 14:34 schrieb [email protected]:
>> 
>> Hi Daniel,
>> 
>> Firstly, thank you for your reply ...
>> 
>> That is what I thought as well but it does not seem to be so simple...
>> 
>> If I look at the data with ccsid 273 I get this "Zakªad"  and with ccsid 870 I get 'Zakład'
>> 
>> If I write the data to UFT-8 File with ccsid 1208 I get the wrong output.
>> 
>> How do I get the correct value to my output file...  Ideas appreciated.
>> 
>> 
>> Mit freundlichen Grüßen / Kind regards / Bien à vous,
>> 
>> Seán
>> 
>> 
>> 
>> 
>> -----Original Message-----
>> From: RPG400-L <[email protected]> On Behalf Of 
>> Daniel Gross
>> Sent: Monday, 30 March 2026 19:46
>> To: [email protected]
>> Subject: Re: Issues with code page conversion..grateful for any help
>> 
>> Hi Sean,
>> 
>> with UTF-8 there is no such thing as a codepage anymore - because UTF-8 is short for "Unicode Transfer Format 8 Bit" - so this is full Unicode.
>> 
>> If you want your file to be written with a specific CCSID, you have to use QSYS2.IFS_WRITE with the FILE_CCSID parameter.
>> 
>> You can also use this function for UTF-8 - that would be FILE_CCSID=>1208 then - as CCSID 1208 would be UTF-8.
>> 
>> HTH
>> Daniel
>> 
>> 
>>>> Am 30.03.2026 um 19:01 schrieb [email protected]:
>>> 
>>> Hello all,
>>> 
>>> 
>>> 
>>> I am using “QSYS2.IFS_WRITE_UTF8” to generate a UTF8 Output file.
>>> 
>>> 
>>> 
>>> So far so good … I have data with Polish special characters that 
>>> must be sent with correct CCSID (870)
>>> 
>>> 
>>> 
>>> I use
>>> 
>>> 
>>> 
>>> EXEC SQL     SET :chr870  = CAST(:myData AS CHAR(100) CCSID 870) to convert my data to CCSID 870 but when I write
>>> 
>>> To my output file the special characters are not written correctly.
>>> 
>>> 
>>> 
>>> Any ides on how to write these special characters to UTF8 without 
>>> losing the code page …
>>> 
>>> I have tried a few things but no success yet…  I am hoping the CCSID guru’s out there have a few ideas for me.
>>> 
>>> 
>>> 
>>> 
>>> 
>>> Mit freundlichen Grüßen / Kind regards / Bien à vous,
>>> 
>>> 
>>> 
>>> Sean
>>> 
>>> 
>>> 
>>> --
>>> This is the RPG programming on IBM i (RPG400-L) mailing list To post 
>>> a message email: [email protected] To subscribe, 
>>> unsubscribe, or change list options,
>>> visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
>>> or email: [email protected]
>>> Before posting, please take a moment to review the archives at 
>>> https://archive.midrange.com/rpg400-l.
>>> 
>>> Please contact [email protected] for any subscription related questions.
>>> 
>> --
>> This is the RPG programming on IBM i (RPG400-L) mailing list To post 
>> a message email: [email protected] To subscribe, 
>> unsubscribe, or change list options,
>> visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
>> or email: [email protected]
>> Before posting, please take a moment to review the archives at https://archive.midrange.com/rpg400-l.
>> 
>> Please contact [email protected] for any subscription related questions.
>> 
>> 
>> --
>> This is the RPG programming on IBM i (RPG400-L) mailing list To post 
>> a message email: [email protected] To subscribe, 
>> unsubscribe, or change list options,
>> visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
>> or email: [email protected]
>> Before posting, please take a moment to review the archives at 
>> https://archive.midrange.com/rpg400-l.
>> 
>> Please contact [email protected] for any subscription related questions.
>> 
> --
> This is the RPG programming on IBM i (RPG400-L) mailing list To post a 
> message email: [email protected] To subscribe, unsubscribe, 
> or change list options,
> visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
> or email: [email protected]
> Before posting, please take a moment to review the archives at 
> https://archive.midrange.com/rpg400-l.
> 
> Please contact [email protected] for any subscription related questions.
> 

--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a message email: [email protected] To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: [email protected]
Before posting, please take a moment to review the archives at https://archive.midrange.com/rpg400-l.

Please contact [email protected] for any subscription related questions.


--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a message email: [email protected] To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: [email protected]
Before posting, please take a moment to review the archives at https://archive.midrange.com/rpg400-l.

Please contact [email protected] for any subscription related questions.


-- 
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: [email protected]
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: [email protected]
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact [email protected] for any subscription related questions.