Skip to content

Commit

Permalink
c_edf.edfopen_file_writeonly now supports utf-8
Browse files Browse the repository at this point in the history
  • Loading branch information
myd7349 committed Sep 5, 2023
1 parent 475a100 commit beb533a
Showing 1 changed file with 0 additions and 17 deletions.
17 changes: 0 additions & 17 deletions pyedflib/_extensions/_pyedflib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -519,23 +519,6 @@ def set_physical_maximum(handle, edfsignal, phys_max):
def open_file_writeonly(path, filetype, number_of_signals):
"""int edfopen_file_writeonly(char *path, int filetype, int number_of_signals)"""

if os.name=='nt' and contains_unicode(path):
default_enc = locale.getdefaultlocale()[1]
if default_enc is None:
default_enc = ''
else:
default_enc = default_enc.lower()
using_unicode = 'utf' in default_enc or 'unicode' in default_enc or \
'10646' in default_enc or default_enc=='cp65001'
# Check if we're on Windows and the file path contains Unicode.
# If so, use workaround to create file: In Python, create the file,
# then look up and pass the short file name to the C library
if not using_unicode:
warnings.warn('Attempting to write Unicode file {} on Windows. ' \
'Consider changing your locale to UTF8.'.format(path))
with open(path, 'wb'): pass
path = get_short_path_name(path)

py_byte_string = path.encode('utf_8','strict')
cdef char* path_str = py_byte_string
return c_edf.edfopen_file_writeonly(path_str, filetype, number_of_signals)
Expand Down

0 comments on commit beb533a

Please sign in to comment.