Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to response non-latin characters in AWS lambda?

Update Oct 12:

The issue is fixed now. See this post in aws forum for details.


I wrote a nodejs function simply respond with some Chinese characters. But it respond with wrong characters.

exports.handler = function(event, context) {
    context.succeed('Hello 世界!');
};

The function result becomes:

"Hello ������������!"

I came across this problem when I wrote a function to parse some Chinese websites and retrieve their page titles. I manage to convert them into utf-8 (I used needle for the request), and console.log(title) correctly display those Chinese characters. But the result from context.succeed() shows up like the example above. What should I do to deal with these non-latin characters when responding the result?

like image 960
Martin Lai Avatar asked Jul 10 '15 15:07

Martin Lai


People also ask

Which languages can Lambda use for serverless code?

Q: What languages does AWS Lambda support? AWS Lambda natively supports Java, Go, PowerShell, Node. js, C#, Python, and Ruby code, and provides a Runtime API which allows you to use any additional programming languages to author your functions.

Can Lambda execute code in response to events?

Lambda is an on-demand compute service that runs custom code in response to events.


1 Answers

From AWS Support (August 10, 2015):

Thank you for reaching out AWS Support with your question about Lambda and UTF-8.

We are presently researching this issue as other customers have brought this to our attention. There is no eta on when this will be resolved or if this is something we can resolve.

like image 53
BestPractices Avatar answered Oct 23 '22 01:10

BestPractices