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



On a 7.2 machine I can use the new keyword CCSID(*CHAR:*UTF8), defining my
char variables with ccsid 1208.
It seems to me that %subst does not substring characters, but bytes.

I'm running some tests, and i obtain these results.
My job ccsid is 1144.
I assign the string '€' (euro sign) to my utf-8 variable CHAR10.

H DECEDIT(*JOBRUN) DATEDIT(*DMY/) DFTACTGRP(*NO) ACTGRP(*CALLER)
H OPTION(*NODEBUGIO)
H CCSID(*UCS2: 1200)
H CCSID(*CHAR:*UTF8)
*
D CHAR10 S 10
D RTCHA1 S 10
D RTCHA2 S 10
D RTCHA3 S 10
C EVAL CHAR10='€'
C EVAL CHAR20=TXT(1)
C EVAL RTCHA1=%SUBST(CHAR10:1:1)
C EVAL RTCHA2=%SUBST(CHAR10:1:2)
C EVAL RTCHA3=%SUBST(CHAR10:1:3)
C EVAL *INLR=*ON

The euro sign hex is E282AC (3 bytes).
If I try to substring CHAR10 I obtain this:
C EVAL RTCHA1=%SUBST(CHAR10:1:1)
RTCHA1 = 'S■■■■■■■■■' hex 'E2202020 20202020 2020'

C EVAL RTCHA2=%SUBST(CHAR10:1:2)
RTCHA2 = 'Sb■■■■■■■■' hex 'E2822020 20202020 2020'

C EVAL RTCHA3=%SUBST(CHAR10:1:3)
RTCHA3 = '€ ' hex 'E282AC20 20202020 2020'

So it seems that %subst does not substring characters, but bytes.
I'm doing something wrong or this is working as expected?
How can I substring CHAR10?
Thanks for any advice.

Marco

As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.