Skip to content

Charset from response / request is not respected #1435

@Wertisdk

Description

@Wertisdk

When we submit a form with Turbo, the response is always decoded as UTF-8, even though the response has a different charset:
> Content-Type: text/html; charset=Windows-1252

The issue with this approach, is that responses encoded in another encoding will have issues with the decoded content.

The root cause is that Response.text() always returns a UTF-8 decoded string, which is being used in src/http/fetch_response.js - get responseHTML to decode the response.

I am unsure if this is also the intended behaviour in Turbo, but I believe it would be safe to implement a TextDecoder that respects the response charset.

I've created a small example where I use a TextDecoder to decode the response in the response charset
d3e9996

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