IBM / xmlservice

XML-based interface for accessing IBM i resources
https://xmlservice.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
35 stars 18 forks source link

How to use pure xml to call PGM/CMDwith Chinese Chars (937)? #52

Closed owen-rpx closed 3 years ago

owen-rpx commented 3 years ago

My web page will input Chinese chars like '測試'

My nodejs will send xml str to XmlService with Post method and the form body like below: `<?xml version="1.0"?>

CHGLIBL LIBL(QGPL QTEMP) 63jo3fzykm0wo0s408w04kw44 USR Test 測試 ` The cmd string: ` CHGLIBL LIBL(LIBNAME QGPL QTEMP) CMD1 SSNID(7kr4yyvy0dk4o8k884k8wkccg) USR(USE) PAE(''A004'')TSKTXT(''測試'') RTNMSG(?) ` **PS: HTTPAdmin already config the CCSSID with 937/950** Could give us the example how to deal with them? thanks. @jimoibm @kadler
jimoibm commented 3 years ago

Can you please show me more details on what the result/error was? Was the URI chars were escaped in the browser? Was the job calling XMLService in the job ccsid as you expected? What ccids was your cmd/pgm expecting for chars encoded with?

owen-rpx commented 3 years ago

@jimoibm @kadler I need to run cmd and store the china chars into DB2. Below is cmd results:

`<?xml version="1.0"?>

` I try encode at my nodejs code but now working. Big5 is charset
jimoibm commented 3 years ago

Are you saying it is working now?

owen-rpx commented 3 years ago

Not working, I use Postman to debug it and Post method url is http://xxx.xxxx.com:portNum/cgi-bin/xmlcgi.pgm The CMD1 is placeholder, yes. I try to use hex='on' as below: `<?xml version="1.0"?>

CHGLIBL LIBL(ACMSALIB QGPL QTEMP) CMD1 SSNID(1i6cvqpz0ce84ws040gc8wsg4) USR(XUDONGZ) PAE(''A002'') RTNMSG(?) TSKTXT(''測試'') ` My web page show missing codes: ![image](https://user-images.githubusercontent.com/3795044/109776705-d7c82700-7c3d-11eb-971b-db2a00844f1d.png) OR give us some example for ccsid convert https://xmlservice.readthedocs.io/en/latest/functions.html?highlight=hex#advanced-ccsid bin2hex('China_ascii_raw_chars') I see the above docs but not get clear solution for CMD/PGM
jimoibm commented 3 years ago

hex='on' means you need to give hexadecimal....
before/after='fromCCSID/toCCSID' you need consider well on your job ccsid/parm ccsid pgm taking in

if using command call, you need to HEX'd all the command string.. You may consider using pgm call for better control of ccsid conversion on the only needed parms

If hit error complaining Argument list too long., it is caused by a bug below if receiver needs to be bigger than input for iconv(). Try using hex without conversion and workaround in your code..

size = anyBIG(index).bigsize; <-- should be bigger for receiver

rc = iconv(conv.conv
          :%addr(fromPtr):%addr(fromBytes)
          :%addr(toPtr):%addr(toBytes));  <-- toBytes should greater than fromBytes

Possible one spot change:

     P cacAddBig       B                   export
     D cacAddBig       PI            10i 0
     D  bsize                        10i 0 value
     D  btype                         1A   value
     ...
       /free
         bsize = bsize * 4;  <--- make a bigger receiver size...
     ....

Command call example:

CHGLIB LIB(JIMOCN) TEXT('中')
935 -> 1208                                                             
hex ->  IN: C3C8C7D3C9C240D3C9C24DD1C9D4D6C3D55D40E3C5E7E34D7D0E5BCF0F7D5D404040404040404040                                        
hex -> OUT: 4348474C4942204C4942284A494D4F434E2920544558542827E4B8AD2729202020202020202020

&ipc=*NA&ctl="*here"&xmlin="<?xml version='1.0'?><cmd hex='on' before='1208/935' after='935/1208'>4348474C4942204C4942284A494D4F434E2920544558542827E4B8AD2729202020202020202020</cmd>"&xmlout=500000

Result:

<?xml version='1.0'?><cmd hex='on' before='1208/935' after='935/1208'><success>+++ success CHGLIB LIB(JIMOCN) TEXT('$õ')</success>
</cmd>