You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’m trying to set up an application that sets the content-type response header dynamically. The goal is to set a charset in the URL (as parameter) and use that value in the header as charset. It’s an application to test a 3rd party integration in various charset / encoding environments.
I tried to set the content type via res.set('content-type': 'text/html; charset=mycharset');
which does not work.
Hi! If you are giving Express a string, Express has to encode that sting into bytes somehow. Express does this by using the universal UTF8 encoding format.
If you are using a different charset, then you're going to have to encode your string into bytes using that charset first and hand Express a Buffer object containing those bytes. Then, Express will not touch the charset, because it did not perform the encoding.
Hey,
I’m trying to set up an application that sets the
content-type
response header dynamically. The goal is to set a charset in the URL (as parameter) and use that value in the header as charset. It’s an application to test a 3rd party integration in various charset / encoding environments.I tried to set the content type via
res.set('content-type': 'text/html; charset=mycharset');
which does not work.
I then got the advice to set it in my
res.render
method but it seemsutf-8
is hardcoded and does not accept any overwrites.Is it simply not possible? If so, may I ask why that is? If there is a solution, can you help me out?
The text was updated successfully, but these errors were encountered: