Handlebars-Net / Handlebars.Net

A real .NET Handlebars engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Question] Is there a way to ensure emoji's are properly handled?

plamber opened this issue · comments

Hi,
First of all. Thank you, a lot, for the work done so far. We are using the latest version of HandlebarsDotNet.

We are trying to convert a template with parameters containing an emoji. Find below a code snippet.

var template = "Put here some text and '{{title}}'";
var params = new { title = "😆Smile has issues" };
var render = Handlebars.Compile(template);
var subject = render(parameters);

The result will be

"Put here some text and '��Smile has issues'";

Is there a way to keep the same output even with emojis?

Thank you for your feedback,
Patrick

Hello @plamber . You see this behavior because of default encoding. In order to preserver emojis you'd need to implement your own encoder or disable it all together.

Hi @zjklee,
Thank you very much. Do you have a suggestion on how such an encoder can be implemented and injected?

Thank you,
Patrick

@plamber

You should have a look at ITextEncoder and HtmlEncoder as its implementation.

Thank you. I will have a look into that.