Skip to content

Chinese char in filename is ignored  #845

@baohengtao

Description

@baohengtao

seems Chinese char is cleaned by this function.

  def clean_filename(filename: str) -> str:
      """Replaces invalid chars in filenames with '_'"""
      result = filename.encode(
          "utf-8").decode("ascii", "ignore")
      invalid = '<>:"/\\|?*\0'
  
      for char in invalid:
          result = result.replace(char, '_')
  
      return result

the output "假期_01.jpg" is "_01.jpg" without Chinese char

In [1]: clean_filename("假期_01.jpg")
Out[1]: _01.jpg  

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