I need to fetch a UTF-8 string from a header in a React Native application like so:
fetch('https://www.example.com', {
method: 'HEAD',
headers: {
'Content-Type': 'text/html; charset=utf-8'
}
}).then((res) => {
console.log(res.headers.get('example-header'))
}
However, I have some german characters such as ü
being logged as ü
.
According to this article, the ü
is being interpreted as ISO 8859-1 (Latin-1)
.
Looking at the response headers, I clearly see Content-Type: text/html; charset=utf-8
Is there a way to ensure the header is properly decoded as UTF-8?
Is it even possible?
It works in the Firefox console.