From 056ecf0d9071c0dfee86bdd343f8b2ec73fd5801 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Wed, 4 May 2022 19:22:18 +0200 Subject: [PATCH] Fix for #2394 --- cps/helper.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cps/helper.py b/cps/helper.py index cb9cb436..91afe727 100644 --- a/cps/helper.py +++ b/cps/helper.py @@ -241,8 +241,7 @@ def get_valid_filename(value, replace_whitespace=True, chars=128): # pipe has to be replaced with comma value = re.sub(r'[|]+', u',', value, flags=re.U) - filename_encoding_for_length = 'utf-16' if sys.platform == "win32" or sys.platform == "darwin" else 'utf-8' - value = value.encode(filename_encoding_for_length)[:chars].decode('utf-8', errors='ignore').strip() + value = value.encode('utf-8')[:chars].decode('utf-8', errors='ignore').strip() if not value: raise ValueError("Filename cannot be empty")