Hi, I work in France.
When I code, I always have problems with French language accents like é, à, ï, which cause bugs in my code. Even when I use encode('utf-8'), it doesn’t work.
ChatGPT told me that Python 2.7 doesn’t support it.
I want to know if pyRevit 5.0 solves this problem. It seems we passed on Python3?
and to serve some chatGPT answer that iw relevant:
The # -*- coding: UTF-8 -*- declaration at the top of a Python file is useful but only affects the encoding of the source code itself. It ensures that non-ASCII characters (like French accents) in string literals are correctly interpreted by the Python interpreter.
Usage
At the very top of your .py file, add:
python
CopierModifier
# -*- coding: UTF-8 -*-
or, equivalently:
# coding: utf-8
When is it needed?
Required in Python 2 if your script contains non-ASCII characters.
Not needed in Python 3, because Python 3 defaults to UTF-8.
Yes, that’s exactly what ChatGPT told me, but unfortunately, it does not work, especially when I want to retrieve data to create a temporary database document. All the data retrieved with accents cause errors when added to the database.