[Bf-extensions-cvs] [8cbad902] master: Fix T64833: FBX Import fails with long names.
Bastien Montagne
noreply at git.blender.org
Wed May 29 11:01:55 CEST 2019
Commit: 8cbad902016d3aee763fc100b59d8f50a560df96
Author: Bastien Montagne
Date: Wed May 29 11:00:06 2019 +0200
Branches: master
https://developer.blender.org/rBA8cbad902016d3aee763fc100b59d8f50a560df96
Fix T64833: FBX Import fails with long names.
Classical stupid issues when trying to shorten an utf8 string to match a
given bytes length... ;)
===================================================================
M io_scene_fbx/__init__.py
M io_scene_fbx/import_fbx.py
===================================================================
diff --git a/io_scene_fbx/__init__.py b/io_scene_fbx/__init__.py
index 818eae23..5d95db6d 100644
--- a/io_scene_fbx/__init__.py
+++ b/io_scene_fbx/__init__.py
@@ -21,7 +21,7 @@
bl_info = {
"name": "FBX format",
"author": "Campbell Barton, Bastien Montagne, Jens Restemeier",
- "version": (4, 14, 11),
+ "version": (4, 14, 12),
"blender": (2, 80, 0),
"location": "File > Import-Export",
"description": "FBX IO meshes, UV's, vertex colors, materials, textures, cameras, lamps and actions",
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')
More information about the Bf-extensions-cvs
mailing list