Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xopen(..., encoding='utf-8') option? #34

Closed
markusdr opened this issue Jul 30, 2020 · 3 comments
Closed

xopen(..., encoding='utf-8') option? #34

markusdr opened this issue Jul 30, 2020 · 3 comments
Assignees

Comments

@markusdr
Copy link

markusdr commented Jul 30, 2020

With the regular open() function, I typically specify the encoding, e.g.,

open(fname, 'r', encoding='utf-8')

Looks like with xopen it's not possible? Would that cause problems when reading UTF-8 encoded text files?

@markusdr markusdr changed the title open(..., encoding=' xopen(..., encoding='utf-8') option? Jul 30, 2020
@rhpvorderman rhpvorderman self-assigned this Jul 30, 2020
@rhpvorderman
Copy link
Collaborator

rhpvorderman commented Jul 30, 2020

Depends on what platform you are at. I believe it will choose the platform default. Usually that's utf-8, but if it's not I think you could run into problems.

xopen wraps all binary steams in a TextIOWrapper when the mode is "r", so I guess it should be doable to pass through the encoding argument.

We can do this with *args, **kwargs so any arguments get passed trough, including encoding.

Thanks for mentioning this!

@rhpvorderman
Copy link
Collaborator

@markusdr This is pending in #81

@marcelm
Copy link
Collaborator

marcelm commented Jan 13, 2022

#81 has been merged and I have just uploaded v1.3.0 to PyPI with this change, so let’s close this!

@marcelm marcelm closed this as completed Jan 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants