Skip to content

UnicodeEncodeError: 'charmap' codec can't encode characters (gen_config.py) #443

@Uttam-Singhh

Description

@Uttam-Singhh

There is a serious problem with the gen_config.py file.
When I was trying to run make hugo command to start building sites.

I was getting the following error again and again:

num1

then I went through the web and searched about this and I found this problem is only for windows users. It is working fine on other OS. This problem is because the encoding is changed to UTF-8 when using the file, so characters in UTF-8 are able to be converted to text, instead of returning an error when it encounters a UTF-8 character that is not supported by the current encoding.

I also searched for a solution and it was to replace: with open(fname, "w") as f: f.write(html)

with this
import io with io.open(fname, "w", encoding="utf-8") as f: f.write(html)

or

with open(fname, "w", encoding="utf-8") as f: f.write(html)

But the first support Python 2 as well. Refer to this LINK for more information.

I have created a PR as well for this issue.
Please check and let me know what you think. @rgommers @InessaPawson @joelachance

My changes are as follows:

num2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions