toddams/RazorLight

Issue with Encoding. Localization, especially Ru language

AndreyMisnikov opened this issue · 2 comments

Hello!

If I define razor light engine as
RazorLightEngine engine = new RazorLightEngineBuilder()
.UseEmbeddedResourcesProject(typeof(RazorModel))
.SetOperatingAssembly(typeof(RazorModel).Assembly)
.UseMemoryCachingProvider()
.Build();

and then use
engine.CompileRenderStringAsync(razorTemplateKey, content, model)

I have the issue with encoding when my content contains Russian.
Is it possible to specify some kind of encoding for Engine by default?

I have created a lot of templates in my project with localization and as temporary fix I use
content = "@using RazorLight @{ DisableEncoding = true; }" + content;

I would like to have an option to set some property to engine and be able to work with any language.

What you are describing as a temporary fix is the de facto approach:

https://github.com/toddams/RazorLight#encoding

If you want to contribute an alternative approach, I am open to shipping a PR.

@AndreyMisnikov any feedback/thoughts?