I’m new on Anvil but I find it very useful and pleasant to work with. I’m trying to build a simple web app with a text area and a button. Everything is fast and easy but I have stumbled upon a little trouble. When the app tries to get_bytes() from a text file it changes special characters like ‘ë’ or ‘ç’ to some gibberish characters. The same app has no trouble to write in the text file the right characters with set_bytes() function. I would really appreciate if someone could help me with that.
If you can manage to get the bytes into a string with the right encoding I think you should be okay.
Let me know if either of these work. I can’t test with your actual file since you are pulling it from your Google environment which I don’t have access to.
It works perfectly with all the special characters. I used the first option.
Thanks a lot. I think I’ll stick with anvil for the comprehensive workflow and its great forum.
This is the right answer, @alcampopiano! When you read the file, you get a bytes object, which represents byte sequences rather than characters. To turn it into a string, you have to decode it with a particular encoding, which tells Python how to interpret those bytes as characters, and that’s what the code snippets you posted do. (For text, utf-8 is almost always the right encoding).