Skip to content

Property names with special characters (ä,ö,ü) are converted to unicode strings #30

Closed

Description

@skriebi

Hello,

some of the columns in our database contains special characters (ä,ö,ü).
The characters are converted to ä, ö or ü unicode strings.

To solve the issue for me, I have created a hbs-helper, which simple writes the property-name with the WriteSafeString-Method of the TextWriter.

Helper registration:

    public void ConfigureDesignTimeServices(IServiceCollection services)
    {
        var options = ReverseEngineerOptions.DbContextAndEntities;
        services.AddHandlebarsScaffolding(options);
        
        Handlebars.RegisterHelper("f-pn", FormatPropertyName);
    }

    void FormatPropertyName(TextWriter writer, object context, object[] args)
    {
        writer.WriteSafeString(args[0].ToString());
    }

Usage in templates:
{{f-pn property-name}}

I think, the property-name template should use the WriteSafeString-Method.

Activity

  1. tonysneed commented on Jul 20, 2018

    @tonysneed
    Contributor

    You should add your helper like so:

    services.AddHandlebarsHelpers(myHelper);

    See here.

    I think, the property-name template should use the WriteSafeString-Method.

    Perhaps you should open an issue on Handlebars.Net, since the templates should use WriteSafeString? I recommend that, because it would solve the problem of special characters globally.

  2. ErikEJ commented on Jul 31, 2018

    @ErikEJ
    Contributor
  3. ErikEJ commented on Jul 31, 2018

    @ErikEJ
    Contributor

    EF Core team (and I) use UTF8 encoding...

  4. tonysneed commented on Dec 17, 2018

    @tonysneed
    Contributor

    @ErikEJ What do you think I should do to fix this?

  5. tonysneed commented on Dec 27, 2018

    @tonysneed
    Contributor

    Confirmed this is a Handlebars.Net issue. There needs to be a way to suppress HTML encoding. See Issue 276 there.

  6. added
    bug
    on Jan 1, 2019
  7. tonysneed commented on Jul 17, 2019

    @tonysneed
    Contributor

    Closing, as this needs to be fixed by Handlebars.NET.

  8. tonysneed commented on Sep 8, 2021

    @tonysneed
    Contributor

    Re-opening, as this issue was fixed in v2 of Handlebars.Net.

  9. Varorbc commented on Sep 24, 2021

    @Varorbc
    Contributor

    If this option is not checked, Chinese will not be encoded.

    image

  10. ErikEJ commented on Sep 24, 2021

    @ErikEJ
    Contributor

    The option is: Use Data Annotations

  11. Varorbc commented on Sep 24, 2021

    @Varorbc
    Contributor

    In addition, it is strange that some Chinese is not encoded

  12. Varorbc commented on Sep 24, 2021

    @Varorbc
    Contributor

    In my investigation, I found that some Chinese are not encoded because SuppressEncoding is true, because I am not familiar with this project and do not know where to assign SuppressEncoding

    https://github.com/Handlebars-Net/Handlebars.Net/blob/ad5c616c58397c6d52507c859cb9f1b397580e3a/source/Handlebars/IO/EncodedTextWriter.cs#L48-L57

  13. tonysneed commented on Sep 24, 2021

    @tonysneed
    Contributor

    This flag was added in Handlebars.Net in v 2 and defaults to true. I think we just need to set it to false.

  14. tonysneed commented on Sep 24, 2021

    @tonysneed
    Contributor

    I am wondering how to reproduce the encoding issue on my side. @Varorbc, @ErikEJ Any tips?

  15. Varorbc commented on Sep 24, 2021

    @Varorbc
    Contributor

    Not so.This flag already exists in Handlebar. Net in V1.I think we should find out why some Chinese SuppressEncoding is false and some Chinese SuppressEncoding is true instead of directly modifying the default value

  16. tonysneed commented on Sep 24, 2021

    @tonysneed
    Contributor

    @Varorbc I think the setting is NoEscape. According to issue 276 in Handlebars.Net, support for noEscape was added to Handlebars.Net with PR 375 in 2.0.0-preview-2. I will look into how we can set this to true.

  17. tonysneed commented on Sep 24, 2021

    @tonysneed
    Contributor

    @Varorbc Please pull down PR #178 and test to see if it resolves encoding issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions