Skip to content

fragment.render encodes norwegian(possibley others as well) characters #38

Closed

Description

@petterek
Dim fragment = CsQuery.CQ.Create(value)
Dim res As String = fragment.Render(CsQuery.DomRenderingOptions.QuoteAllAttributes Or CsQuery.DomRenderingOptions.RemoveComments)

The Norwegian charcters æøå gets HTMLEncoded to &# xxx; format

Maybe add an option to CsQuery.DomRenderingOptions to keep such characters

Activity

  1. jamietre commented on Sep 5, 2012

    @jamietre
    Owner

    Yes, I agree this should be an option. The target for the Render method has always been for a web browser, where it doesn't make a difference since the browser stores internally as unicode whichever way the source comes. But if you were going to extract text from the output of Render, this could be a problem. Should not be hard to add.

  2. jamietre commented on Sep 5, 2012

    @jamietre
    Owner

    Addressed in last commit: 508ef41

    I added two new DomRenderingOptions to either stop encoding altogether HtmlEncodingNone --which may not produce valid HTML -- or only encode carets and ampersands HtmlEncodingMinimum -- which should still produce valid HTML but won't encode any unicode or other characers.

    Not 100% thrilled about adding non-boolean value to DomRenderingOptions. That is, this should be an option, not two flags that overlap. So this API may change before the next release - I might make the config into an object with properties beyond just the flags.

  3. petterek commented on Sep 5, 2012

    @petterek
    Author

    Superb working..

    Sendt fra en Samsung Mobil

    James Treworgy notifications@github.com skrev:

    Yes, I agree this should be an option. The target for the Render method has always been for a web browser, where it doesn't make a difference since the browser stores internally as unicode whichever way the source comes. But if you were going to extract text from the output of Render, this could be a problem. Should not be hard to add.

    —
    Reply to this email directly or view it on GitHubhttps://github.com//issues/38#issuecomment-8302292.

  4. jamietre commented on Oct 9, 2012

    @jamietre
    Owner

    Made significant changes to the model for rendering, the code is in the current push. This is going to break anything you may have coded against DomRenderingOptions.HtmlEncodingxxx. The new model uses an interface to describe an output formatter, of which there are a lot of defaults, or you can compose one from a combination of DomRenderingOptions flags and an HTML encoder defined using the IHtmlEncoder interface.

    It's a bit more complicated but provides unlimited flexibility, and there are built-in objects for all common cases that are accesible from a simple factory. Docs here.

    https://github.com/jamietre/CsQuery/blob/master/documentation/output.md

    All you should have to do to update is (for example) if you were using

    var html =  dom.Render(DomRenderingOptions.HtmlEncodingMinimum);
    

    would be to change to:

    var html = dom.Render(OutputFormatters.HtmlEncodingMinimum);
    

    There are a lot more possibilities now though, see the docs for more details. I'm happy with this model and this will likely be in the final release of 1.3 (hopefully very soon!).

  5. petterek commented on Oct 10, 2012

    @petterek
    Author

    Worked very well.
    All my testes passed.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions