xarray
xarray copied to clipboard
add **encoding** argument in netCDF4 backend
add encoding argument in netCDF4 backend to support reading NetCDF file with non-ASCII path or filename.
The behavior is consistent with upstream netCDF4 library, default path encoding is set to sys.getdefaultfileencoding() .
- [x] Closes #10357 #8531
Thank you for opening this pull request! It may take us a few days to respond here, so thank you for being patient. If you have questions, some answers may be found in our contributing guidelines.
Nice, can you add a test here please? https://github.com/pydata/xarray/blob/d589df1868b9d6ec197a91da7e3acb8670bb7641/xarray/tests/test_backends.py#L2037
It can simply roundtrip a simple dataset to a file with a filename that doesn't work today.
How is this handled in the light of this comment https://github.com/pydata/xarray/issues/9282#issuecomment-2310573129 by @dcherian?
Hah! Probably good to use filename_encoding since we'll probably to support writing files with such file names.