LANSA Integrator: Machine-dependent characters are garbled when executed on Windows

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
Yukiko Ikeo
Posts: 12
Joined: Fri Jun 09, 2017 11:58 pm

LANSA Integrator: Machine-dependent characters are garbled when executed on Windows

Post by Yukiko Ikeo » Mon May 03, 2021 1:23 pm

Hi All,

product: LANSA Integrator
version: V15 EPC150030
Windows OS: Windows Server 2016, Windows10

Our customer uses SMTPMailService to send e-mails.
They reported that Machine-dependent character '㈱' is garbled.
I've tested and found that:
- It garbles when runninig on Windows only. (It doesn't garble when running on IBM i.)
- Unicode for this character is U+3231.
https://www.compart.com/en/unicode/U+3231
- Not only SMTPMailService but also ExcelService was garbled when writing this character.
- It seems that LANSA Integrator on Windows can't handle certain Unicode characters.

My test program RDMLX:

Code: Select all

Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) Clientheight(414) Clientwidth(585) Height(452) Left(471) Top(168) Width(600)

Define_Com Class(#PRIM_STBR) Name(#STBR_1) Displayposition(8) Height(24) Left(0) Messageposition(1) Parent(#COM_OWNER) Tabposition(8) Tabstop(False) Top(390) Width(585)

Define_Com Class(#JSMEMAIL.Visual) Name(#toaddress) Caption('To') Displayposition(2) Labeltype(Caption) Left(8) Marginleft(80) Parent(#COM_OWNER) Tabposition(2) Top(8) Height(21) Usepicklist(False) Width(839)
Define_Com Class(#JSMEMAIL.Visual) Name(#ccaddress) Caption('CC') Displayposition(4) Labeltype(Caption) Left(8) Marginleft(80) Parent(#COM_OWNER) Tabposition(4) Top(32) Height(21) Usepicklist(False) Width(839)
* Define_Com Class(#JSMEMAIL.Visual) Name(#Subject) Caption('Subject') Displayposition(7) Labeltype(Caption) Left(8) Marginleft(80) Parent(#COM_OWNER) Tabposition(7) Top(56) Height(21) Usepicklist(False) Width(839)
Define_Com Class(#STD_NVARC.Visual) Name(#Subject) Caption('Subject') Displayposition(6) Labeltype(Caption) Left(8) Marginleft(80) Parent(#COM_OWNER) Tabposition(6) Top(56) Height(21) Width(839)

Define_Com Class(#JSMEMAIL.Visual) Name(#fromaddress) Caption('From Address') Displayposition(9) Labeltype(Caption) Left(8) Marginleft(80) Parent(#COM_OWNER) Tabposition(9) Tabstop(False) Top(80) Visible(False) Width(3) Height(21) Usepicklist(False)
Define_Com Class(#JSMEMAIL.Visual) Name(#fromname) Caption('From Name') Displayposition(7) Labeltype(Caption) Left(8) Marginleft(80) Parent(#COM_OWNER) Tabposition(7) Tabstop(False) Top(104) Visible(False) Width(3) Height(21) Usepicklist(False)

Define_Com Class(#PRIM_PHBN) Name(#Send) Caption('Send') Displayposition(3) Left(24) Parent(#COM_OWNER) Tabposition(3) Top(360) Width(100)
Define_Com Class(#PRIM_PHBN) Name(#Reset) Caption('Reset') Displayposition(5) Left(136) Parent(#COM_OWNER) Tabposition(5) Top(360) Width(100)
Define_Com Class(#PRIM_MEMO) Name(#message) Componentversion(1) Currentline(1) Displayposition(1) Height(273) Left(8) Maximumlinelength(250) Parent(#COM_OWNER) Showselectionhilight(False) Tabposition(1) Top(80) Width(553) Wordwrap(True)
Define_Com Class(#PRIM_MECL) Name(#messageline) Columnrole(Data) Displayposition(1) Parent(#message) Source(#jsmemail)
Define_Com Class(#PRIM_MECL) Name(#MECL1) Columnrole(LineNumber) Displayposition(2) Parent(#message) Source(#STD_TEXT)

Define Field(#pos) Type(*DEC) Length(3) Decimals(0)
Define Field(#start) Type(*DEC) Length(3) Decimals(0)
Define Field(#filename) Type(*CHAR) Length(255)

Def_List Name(#filelist) Fields(#filename) Type(*WORKING)
Def_List Name(#tolist) Fields(#jsmemail) Type(*WORKING)
Def_List Name(#cclist) Fields(#jsmemail) Type(*WORKING)

Evtroutine Handling(#com_owner.Initialize)
Set Com(#com_owner) Caption(*component_desc)

#jsmhdle := *default
#fromaddress := ikeo@lansa.jp
#fromname := 'LANSA Product Centre'

* JSMのオープン
Use Builtin(jsmx_open) With_Args('localhost:4560') To_Get(#jsmsts #jsmmsg #jsmhdle)
* Use Builtin(jsmx_open) To_Get(#jsmsts #jsmmsg #jsmhdle)
#com_owner.check( #jsmsts #jsmmsg )


* サービスのロード
#jsmcmd := 'service_load service(SMTPMailService) trace(*yes)'
Use Builtin(jsmx_command) With_Args(#jsmhdle #jsmcmd) To_Get(#jsmsts #jsmmsg)
#com_owner.check( #jsmsts #jsmmsg )
Message Msgtxt('SMTPMailService loaded')

#toaddress := 'ikeo@lansa.jp'
#Subject := (12849).AsUnicodeString
Endroutine

Mthroutine Name(SendEmail)

If (*Not #jsmhdle.isnull)

* from details (ideally these should be set up in your SMTPMailService.properties file)
* FROM の設定
#jsmcmd := 'set from(' + #fromaddress + ') from_name(' + #fromname + ')'
Use Builtin(jsmx_command) With_Args(#jsmhdle #jsmcmd) To_Get(#jsmsts #jsmmsg)
#com_owner.check( #jsmsts #jsmmsg )

* TO の設定
Clr_List Named(#tolist)
#start := 1
Dountil (#pos = 0)

If (#toaddress.cursize > #start)
#pos := #toaddress.positionof( ';', #start )
Else
#pos := 0
Endif

If (#pos = 0)
#jsmemail := #toaddress.substring( #start )
Else
#jsmemail := #toaddress.substring( #start, (#pos - #start) )
#start := #pos + 1
Endif

If (#jsmemail *NE *blank)
Add_Entry To_List(#tolist)
Endif

Enduntil
Use Builtin(jsmx_command) With_Args(#jsmhdle 'set to(*list) ') To_Get(#jsmsts #jsmmsg #tolist)
#com_owner.check( #jsmsts #jsmmsg )

* CC の設定
Clr_List Named(#cclist)
#start := 1
Dountil (#pos = 0)

If (#ccaddress.cursize > #start)
#pos := #ccaddress.positionof( ';', #start )
Else
#pos := 0
Endif

If (#pos = 0)
#jsmemail := #ccaddress.substring( #start )
Else
#jsmemail := #ccaddress.substring( #start, (#pos - #start) )
#start := #pos + 1
Endif

If (#jsmemail *NE *blank)
Add_Entry To_List(#cclist)
Endif

Enduntil
Use Builtin(jsmx_command) With_Args(#jsmhdle 'set cc(*list)') To_Get(#jsmsts #jsmmsg #cclist)
#com_owner.check( #jsmsts #jsmmsg )

* ★サーバーの設定
#jsmcmd := 'set SERVER(smtp.office365.com) USER(J008@lansa.jp) PASSWORD(xxxxx) SECURE(*EXPLICIT) CHARSET(UTF-8) ENCODING(UTF-8)'
Use Builtin(jsmx_command) With_Args(#jsmhdle #jsmcmd) To_Get(#jsmsts #jsmmsg)
#com_owner.check( #jsmsts #jsmmsg )


* メール送信
#jsmcmd := 'send subject(' + (12849).AsUnicodeString + ')'

Use Builtin(jsmx_command) With_Args(#jsmhdle #jsmcmd) To_Get(#jsmsts #jsmmsg #message)
#com_owner.check( #jsmsts #jsmmsg )
Message Msgtxt('Email has been sent')

Endif

Endroutine

* send the email

Evtroutine Handling(#Send.Click)

#com_owner.SendEmail

Endroutine

* reset the email variables

Evtroutine Handling(#Reset.Click)

Clr_List Named(#message)

#toaddress #ccaddress #subject := *blank

Endroutine

* check the JSM return status

Mthroutine Name(check)
Define_Map For(*INPUT) Class(#jsmsts) Name(#i_status)
Define_Map For(*INPUT) Class(#jsmmsg) Name(#i_message)

Message Msgtxt(#i_status + ' :' + #i_message)

Endroutine

Evtroutine Handling(#com_owner.closing) Options(*noclearmessages *noclearerrors)

* Unload service
Use Builtin(jsmx_command) With_Args(#jsmhdle 'Service_Unload') To_Get(#jsmsts #jsmmsg)
#com_owner.check( #jsmsts #jsmmsg )


* Close the thread
Use Builtin(jsmx_close) With_Args(#jsmhdle) To_Get(#jsmsts #jsmmsg)
#com_owner.check( #jsmsts #jsmmsg )

Endroutine

End_Com
Sent mail:
mail_result.PNG
mail_result.PNG (28.25 KiB) Viewed 3156 times
The customer wants to use this character.
Does anyone has any idea for workaround?

Thanks in advance.
Best regards, Yukiko Ikeo

BrendanB
Posts: 52
Joined: Tue Nov 24, 2015 10:29 am

Re: LANSA Integrator: Machine-dependent characters are garbled when executed on Windows

Post by BrendanB » Mon May 03, 2021 3:17 pm

Hi Yukiko,

It is not clear from your code what the definitions of the following are:

#jsmcmd
#jsmmsg
#jsmsts

I suspect that they may be defined as type Char(500) or similar.

if you put some definitions at the top of your form:

Code: Select all

Define Field(#u_jsmcmd) Type(*NVARCHAR) Length(1024)
Define Field(#u_jsmsts) Type(*NVARCHAR) Length(512)
Define Field(#u_jsmmsg) Type(*NVARCHAR) Length(512)
and do a replace all on your code for:

#jsmcmd --> #u_jsmcmd
#jsmsts --> #u_jsmsts
#jsmmsg --> #u_jsmmsg

you may get an error with the Method 'Check', if so, change the definition to:

Code: Select all

Mthroutine Name(check)
Define_Map For(*INPUT) Class(#prim_dc.UnicodeString) Name(#i_status)
Define_Map For(*INPUT) Class(#prim_dc.UnicodeString) Name(#i_message)

Message Msgtxt(#i_status + ' :' + #i_message)

Endroutine
This should allow windows to get the proper characters.

Please try that and report back if it worked.

Yukiko Ikeo
Posts: 12
Joined: Fri Jun 09, 2017 11:58 pm

Re: LANSA Integrator: Machine-dependent characters are garbled when executed on Windows

Post by Yukiko Ikeo » Tue May 04, 2021 5:39 pm

Hi BrendanB,

Thank you for your reply.
I could solve the problem according to your guidance.
キャプチャ.PNG
キャプチャ.PNG (17.09 KiB) Viewed 3134 times
As you suspected, I've defined jsm field in my repository as below:
#jsmcmd alpha 256
#jsmmsg alpha 255
#jsmsts alpha 20

After I changed my code to use NVarChar, it worked okay on Windows.
I appriciate for your help.

Best regards, Yukiko Ikeo

Post Reply