Python FBX Exporter on Japanese Computer, how to convert Ainsi to UTF 8

Hello to all!!
I hope you are all well in those hard times.

I use a Japanese computer, with Blender 2.8 installed, when I export in FBX format, the file is encoded into AINSI. This is a file format specific to Japan.

I guess this is the origin of the problem. (I am assuming that FBX file is alphabetical content.)

I am searching for a way for my FBX export to be encoded in UTF 8.

I tried Notepad++, it is not not working.

A suggestion from a member, Cotaks, told me that i shoul encode inside Blender.

file = open('blabla.txt','w', encoding='utf8')
file.write(your details that you want to save)
file.close()

It was a bright idea,
I found the file " in charge" of the exporting:
export_fbx_bin
But it is fairly complicated.

First question,
does my guess is right, that FBX export a text file containing all the data?

Edit:
The console is saying this.

Traceback (most recent call last):
File “C:\Program Files\Blender Foundation\Blender 2.82\2.82\scripts\addons\io_scene_fbx_init_.py”, line 635, in execute
return export_fbx_bin.save(self, context, **keywords)
File “C:\Program Files\Blender Foundation\Blender 2.82\2.82\scripts\addons\io_scene_fbx\export_fbx_bin.py”, line 3205, in save
ret = save_single(operator, context.scene, depsgraph, filepath, **kwargs_mod)
File “C:\Program Files\Blender Foundation\Blender 2.82\2.82\scripts\addons\io_scene_fbx\export_fbx_bin.py”, line 3110, in save_single
file.write(root)
TypeError: write() argument must be str, not FBXElem

Based on the error message looks like a bug and not related to encoding.

First idea to try is to get the 2.83 beta and try to export again, see if there is the same problem. https://builder.blender.org/download/

Also another idea is to ensure that the encoding configurations in your PC are correct. You can write this just before the crash and then evaluate expressions. import pdb; pdb.set_trace()
https://docs.python.org/3/library/pdb.html

Test all required variables, so you are sure that their encoding is correct. And they are correctly passed to functions. Open your Blender console window, and then when debugger is active, use only [s] / [n] to browse lines or [p] to evaluate expression.
eg: https://stackoverflow.com/questions/12053107/test-a-string-if-its-unicode-which-utf-standard-is-and-get-its-length-in-bytes

1 Like

First cont : Thanks!!!
I will Edit this to keep the track.
I will may be ask for more help…

If you have any other questions I can help.

I erased the too long copy of the problem;
Here it is
https://pastebin.com/wxGya33K

Ideas:

  1. Ensure that Blender 2.83 can export FBX correctly. 2.82 will be toast in a few months so better go for 2.83 to do your tests. You will have to use some specific engine to test it. If you have Unity you can do it there. If you like use Godot as well since is very small and portable. Only look at the result if the export result is fine.

  2. Ensure that the Python can write utf-8. Although Python by default is utf8 is only about process of elimination. Go to text editor and type the code below. Then go to blender.exe directory and you will see the file “text.txt”. Ensure that the file is utf8. I tried it as well in my PC. You should see the same result.

f = open("test.txt", "w")
f.write("hello from blender")
f.close()

2020-05-21 20_30_57-untitled - Sublime Text

  1. There might be a chance that Windows is stubborn. There were many problems with encoding. Now as I read Windows 10 about November 2019 might have an update that fixes the problem, I have not tested it though. You might have to setup Windows in a virtual machine using USA/English settings and then do the same tests. You might otherwise try to install your UI language later on. But the setup would be much safer if done purely in English. I have no idea if this correct, tests are needed. :slight_smile:

These two tests are important to do so you can ensure that everything is correct.

  • Blender FBX exporter
  • Python encoding
  • Windows locale / encoding.

The HAXE part can come later if needed, is another part ontop of the existing issues.

Thanks!!! I will do all that progressively. Nice!

Edit:
Step 1 completed.
I shift to Blender 2.83.
I import Godot. And imported inside it the FBX file.
I dind’t search much for the textures, but no problem for mesh and Animations.

Step 2 completed.
From the console or from text editor the result is the same. a Nice UTF8 file.

I can not do the Step 3, because It’s not my computer.

But really satisfied to understand that the exported FBX file look like to be ok.

OK,
I continue to share the situation.
The compile time FBX to HMD seams to be the problem.
The Encoding, my first assumption, is not the problem.