Skip to main content

Hi everyone,

 

I have created a bot that retrieves e-mails with the Microsoft Graph API. However, the result must be properly encoded using unicode. For example the letter “è” is U+00E8 and if I don’t correct it, the word “règlement” appears as “ru00e8glement“

I have used the javascript component, to run this function :

 

function decodeUnicode(str) {
    return str.replace(/\\ut\dA-F]{4}/gi, function(match) {
        return String.fromCharCode(parseInt(match.replace(/\\u/g, ''), 16));
    });
}

 

However, it is particularly slow.

If I run this script on a batch of 100 e-mails, it takes roughly two minutes. In my opinion, it is not an acceptable duration. Is there a way to optimize that ?

Update : it is equally slow in vbscript, and does not work in python (why ? no idea, there is no logging/no information on why it fails)


I ended up doing a String:replace for every character I found could appear (I have more or less 40 lines of String:replace commands) and it takes less than 10 seconds.

It is really awful for the javascript component to be that inefficient


We have several email functions that are already Unicode safe. Are you using the right tool for the job?


We have several email functions that are already Unicode safe. Are you using the right tool for the job?

The end-user customer won’t let us use the IMAP functions, I have no choice but to use the Microsoft graph API.


Stepping back, there is logging for Python in the bot runner logs.

C:\ProgramData\AutomationAnywhere\BotRunner\Logs

Look through the Node Manager for that info. Python, JavaScript and those are handed to the OS. I’m surprised it is that slow.

A quick glance online shows the FTFY library in Python could help solve your issue.


Reply