How to get the Logic GET request to output correct encoding?

Hi everyone

I am making a GET request to the Danish webpage DOFbasen - af Dansk Ornitologisk Forening

This page of course has content with the Danish special characters: æ, ø and å (Æ, Ø and Å)

However, I am REALLY strugling with how to get Homey to understand that the output needs to be interpreted as charset=iso-8859-1 and not UTF-8.

No matter what I try (like adding Accept-Charset: ISO-8859-1 in the header or trying to use a javascript function to replace the special characters), the output in Homey always shows the Danish special characters as �.

I had come to the conclusion that it had to be an error in Homey that it always insists on interpreting the output as UTF-8, so I even reported it to Athom as a bug… And after 2 weeks I got a useless and arrogant response:

While we’d love to assist you, we focus on general support and can’t dive into user-specific configurations.

We’ll close this ticket, but we wish you all the best in finding the answer you need!

So I guess it is something which I am in control of - just not sure how.

Does anyone here have any idea on how to get Homey to display the correct characters as the outputted response?

Another victim of Athom’s new AI-powered support system :man_shrugging:t3:

It’ll be impossible with Homey flow cards, since those will almost certainly assume UTF-8.

Here’s a quick PoC for HomeyScript:

const url = 'https://dofbasen.dk/search/result.php?design=table&soeg=soeg&periode=antaldage&dage=7&omraade=lokal&lokal=584&artdata=art&hiddenart=08460&obstype=observationer&species=alle&sortering=dato';

const TextDecoder = (this.constructor.constructor("return TextDecoder"))();
const response = await fetch(url);
const buffer = await response.arrayBuffer();
const decoder = new TextDecoder('iso-8859-1');
const text = decoder.decode(buffer);

console.log(text);
1 Like

Thanks so much!

It works using the Homeyscript instead of the logic card.

So annoying that Athom doesn’t acknowledge this or at least hint at using a Homeyscript instead of their own logic card.

They are sending out the exact same response to a lot of other users, which is why I think they starting using a (faulty) AI to handle support requests.

1 Like