Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2019-05-29 12:00:06 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-05-29 12:01:51 +0300
commit8cbad902016d3aee763fc100b59d8f50a560df96 (patch)
treefd48032116692ffdc5bbaaaca7c0a5f025f96eb9 /io_scene_fbx/import_fbx.py
parent8a13d1ed8daa6dbed277e9200da5fe96f85cb35f (diff)
Fix T64833: FBX Import fails with long names.
Classical stupid issues when trying to shorten an utf8 string to match a given bytes length... ;)
Diffstat (limited to 'io_scene_fbx/import_fbx.py')
-rw-r--r--io_scene_fbx/import_fbx.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py
index 624ea2f7..5957f837 100644
--- a/io_scene_fbx/import_fbx.py
+++ b/io_scene_fbx/import_fbx.py
@@ -70,7 +70,12 @@ def validate_blend_names(name):
if len(name) > 63:
import hashlib
h = hashlib.sha1(name).hexdigest()
- return name[:55].decode('utf-8', 'replace') + "_" + h[:7]
+ n = 55
+ name_utf8 = name[:n].decode('utf-8', 'replace') + "_" + h[:7]
+ while len(name_utf8.encode()) > 63:
+ n -= 1
+ name_utf8 = name[:n].decode('utf-8', 'replace') + "_" + h[:7]
+ return name_utf8
else:
# We use 'replace' even though FBX 'specs' say it should always be utf8, see T53841.
return name.decode('utf-8', 'replace')