ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Calling ICU APIs from RPG

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Calling ICU APIs from RPG

    I'm trying to call an ICU APIs from RPG but can't get it running and i think its due to parameter mismatch.
    https://unicode-org.github.io/icu-do.../uidna_8h.html - API "uidna_IDNToASCII()"


    My code looks like following:

    Code:
    **free
    Ctl-Opt BndDir('QICU/QXICUAPIBD');
    
    //************************************************** **
    // Prototypes *
    //************************************************** **
    Dcl-Pr StrToPunycode Int(10) ExtProc('uidna_IDNToASCII_4_0');
      Src Uns(5) Value;
      SrcLen Int(10);
      Dest Uns(5) Value;
      DestCapacity Int(10);
      Options Int(10);
      ParseError LikeDs(ParseError);
      ErrorCode Int(10);
    End-Pr;
    
    //************************************************** **
    // Variables *
    //************************************************** **
    Dcl-Ds Src Qualified;
      Dec Uns(5) Inz(0);
      Value UCS2(64) Pos(1);
    End-Ds;
    
    Dcl-Ds Dest Qualified;
      Value UCS2(64) Inz('');
      Dec Uns(5);
    End-Ds;
    
    Dcl-S DestCapacity Int(10);
    Dcl-S Options Int(10);
    Dcl-S ErrorCode Int(10);
    Dcl-S Len Int(10);
    Dcl-S SrcLen Int(10);
    
    Dcl-Ds ParseError Qualified;
      Line Int(10);
      Offset Int(10);
      Dcl-Ds PreContext;
        Value UCS2(32) Inz('');
        Dec Uns(5) Pos(1);
      End-Ds;
      Dcl-Ds PostContext;
        Value UCS2(32) Inz('');
        Dec Uns(5) Pos(1);
      End-Ds;
    End-Ds;
    
    //************************************************** **
    // Main *
    //************************************************** **
    Src.Value = 'HALLĂ–.COM';
    SrcLen = %Len(Src.Value);
    DestCapacity = %Size(Dest.Value);
    Options = *Zero;
    
    Len = StrToPunycode(Src.Dec :
                         SrcLen :
                       Dest.Dec :
                   DestCapacity :
                        Options :
                     ParseError :
                     ErrorCode) ;
    
    *INLR = *On;
    I think i got the Int(10) Parameters right but the UCHAR (Src, Dest, ParseError) Parameters seem wrong. Does anyone know how to define the UCHAR Parameters in RPG.

    Thanks in advance
    Luca Altmann
Working...
X