Change text variable to UTF-8

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
rullbandspelare
Pro Scripter
Posts: 149
Joined: Tue Mar 23, 2004 9:11 pm

Change text variable to UTF-8

Post by rullbandspelare » Fri Feb 03, 2017 11:06 pm

Hi
I need to telnet into a host and send a text string. But it has to be a UTF-8 encoded string.
How can this be done ? I do not whant to write to a file first. Is VBscript the way to do it?

Like this:
Let>M=åäöÅÄÖ%CR%
UTF8encode>M,text // command that I like to have
TelnetConnect>IP,Port,hTN
-wait>.5
TelnetSend>hTN,%text%



Thanks!

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Change text variable to UTF-8

Post by Marcus Tettmar » Sat Feb 04, 2017 7:56 am

The telnet protocol only supports ANSI and Binary. Currently Macro Scheduler's Telnet implementation is ANSI only.

So you would need to use an alternative Telnet client or Telnet component via VBScript or maybe Python in order to do this.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

rullbandspelare
Pro Scripter
Posts: 149
Joined: Tue Mar 23, 2004 9:11 pm

Re: Change text variable to UTF-8

Post by rullbandspelare » Sat Feb 04, 2017 4:29 pm

Thanks, I have a feeling this can be fixed..
I think that it is possible to exchange the åäö characters in the variable with its utf-8 multi byte equivalent.
As explained in this good answer, (Is the MS telnet client binary 8bit?):
http://stackoverflow.com/questions/2562 ... g-in-utf-8

For example:
StringReplace>M,å,ä,M
or use the VBEval>Chr() method or similar.

What do You think.

will have to test this at work on monday.

rullbandspelare
Pro Scripter
Posts: 149
Joined: Tue Mar 23, 2004 9:11 pm

Re: Change text variable to UTF-8

Post by rullbandspelare » Mon Feb 06, 2017 10:07 am

Hi again!
This works very well.
Telnet itself does not understand the encoding. It only sends the 8bit characters. But the recieving system gets confused if it is not UTF-8 encoded characters.
So the solution was to replace the ANSI 'å' character with its UTF-8 counterpart = 'ä'
like this:
StringReplace>ANSIText,å,ä,UTF8Text

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts