Skip to content

Is UTF-8 supported inside placeholders ? #416

@sylvain-pajaud

Description

@sylvain-pajaud

Hi,

I'm currently trying to use Handlebars.NET (2.0.4)
One of the need I have is to use Japanese "placeholders" (thus with UTF-8 and not ASCII)

Here is an example with Handlebar.js:

https://handlebarsjs.com/playground.html#format=1&currentExample=%7B%22template%22%3A%22Hello%20%7B%7B%E5%A7%93%7D%7D%20%7B%7B%E5%90%8D%7D%7D%2C%5Cn%22%2C%22partials%22%3A%5B%5D%2C%22input%22%3A%22%7B%5Cn%20%20%E5%90%8D%3A%20%5C%22%E5%A4%AA%E9%83%8E%5C%22%2C%5Cn%20%20%E5%A7%93%3A%20%5C%22%E5%B1%B1%E7%94%B0%5C%22%5Cn%7D%5Cn%22%2C%22output%22%3A%22Hello%20%E5%B1%B1%E7%94%B0%20%E5%A4%AA%E9%83%8E%2C%5Cn%22%2C%22preparationScript%22%3A%22%22%2C%22handlebarsVersion%22%3A%224.7.6%22%7D

So it seems it works well on the JS version

Unfortunately, when I try the same thing with the .NET version the parsing fail with an error like this:
": 'Reached unparseable token in expression: 姓}}"

Interestingly, if I name my placeholder starting with ASCII characters (ex: {{a姓}}, or {{_姓}}) it works well no matter how many UTF-8 characters there is inside the placeholder

So it really seems that the first character is somehow important

Is this a limitation of the .NET implementation ? Or maybe I need to change some settings ?

In the worst case I'm thinking, maybe I can do a pre-treatment to change placeholders like {{姓}} into something like {{_姓}}
But it's still a cumbersome, so if some solution can be found I would be happy

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions