Handlebars.Net icon indicating copy to clipboard operation
Handlebars.Net copied to clipboard

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

Open plamber opened this issue 2 years ago • 4 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

plamber avatar Nov 03 '22 11:11 plamber

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.

oformaniuk avatar Feb 15 '23 21:02 oformaniuk

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 avatar Feb 16 '23 06:02 plamber

@plamber

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

oformaniuk avatar Feb 16 '23 22:02 oformaniuk

Thank you. I will have a look into that.

plamber avatar Feb 17 '23 12:02 plamber