× 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 8/15/2016 11:28 AM, Ali Ekinci wrote:
I have a RPGLE program that is a wrapper to a java program that
inputs a string and returns string as well. Then rpg converts java
string to type A varying length output variable via
java.lang.String.getBytes method. Now changing my RPGLE to work with
Unicode parameters. String constractors seemed to worked with type C
inputs, but couldn't figure out how to convert java string to type C
varying length.

Thanks for any help in advance.


If you are on 7.2, you could use getBytes with CCSID(*UTF8) on the prototype for getBytes, and receive the value in a UCS-2 variable.

dcl-pr getbytes varchar(65535) ccsid(*utf8)
extproc(*java : 'java.lang.String' : 'getBytes');
end-pr;
dcl-s val varucs2(65535);
val = getbytes (str);

Otherwise, there is a getChars() method, but it is not as easy to call as getBytes().

https://docs.oracle.com/javase/7/docs/api/java/lang/String.html

dcl-pr stringLength int(10) extproc(*java : 'java.lang.String'
: 'length');
end-pr;
dcl-pr getChars extproc(*java : 'java.lang.String'
: 'getChars');
srcBegin int(10) value;
srcEnd int(10) value;
result ucs2(65535) options(*varsize);
dstBegin int(10) value;
end-pr;
dcl-s len int(10);
dcl-s buf ucs2(65535);

len = stringLength (str);
if len > %len(buf);
len = %len(buf);
dsply 'string is too big';
endif;
getChars (str : 0 : len : buf : 0);
val = %subst(buf : 1 : len);


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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.