Skip to main content
PT Wang
Visitor II
February 15, 2017
Question

STM32CubeMX UTF8 source file merge bug

  • February 15, 2017
  • 7 replies
  • 3305 views

Posted on February 15, 2017 at 04:28

It seems STM32CubeMX can not handle well with UTF8 source file.

If my main.c is encoded in UTF8, regenerating code in 

STM32CubeMX will lead to a scrambled mess. Characters above ASCII range are converted to gibberish, even if they are in user code section. It's nonsense.

https://community.st.com/s/topic/0TO0X000000BTr8WAG/stm32cubemx

This topic has been closed for replies.

7 replies

Technical Moderator
February 15, 2017
Posted on February 15, 2017 at 09:22

Hello,

I will report your issue internally for more investigation and we come back to you as soon as possible.

Best Regards

Imen

"When your question is answered, please close this topic by clicking ""Accept as Solution"".ThanksImen"
Jeanne Joly
Associate
March 17, 2017
Posted on March 17, 2017 at 09:30

Hello

pt.****

,

Could you please send us the ioc you use when your reported this issue?

BR. Eric

Jeanne Joly
Associate
March 31, 2017
Posted on March 31, 2017 at 15:49

Hello

pt.****

,

I think it is not an issue with CUbeMX and more an issue with the IDE you use.

By any chance, are you using IAR?

Because, in fact, if you open directly the generated files with notepad++ (for instance), you will see that you don't have any

gibberish. However, when you open these same files with IAR, sometimes, we saw that some specific characters are changed by IAR.

Hope it will help you.

BR. Eric

Anju Hirano
Associate
August 25, 2017
Posted on August 25, 2017 at 10:45

Hello.

I am troubled with the same symptoms.

The version of CubeMX is 4.22.0.

The development environment is SW4STM32.

The reproduction method is explained below.

1. Generate the code with CubeMX.

2. Open the project with SW4STM32 and change the character code of the project to UTF-8.

3. Open main.c and add Japanese characters to the USER CODE area.

4. Quit SW4STM32.

5. Start CubeMX and generate the code again without changing anything.

6. When SW4STM32 is started and main.c is opened, it can be confirmed that garbled characters are occurring. You can also check garbled characters in the text editor.

From this, I think that CubeMX has the cause of garbled characters.

Is there a character code setting for CubeMX?

Best Regards

Yas

Juichi Ninomae
Visitor II
April 7, 2018
Posted on April 07, 2018 at 07:31

This issue doesn't occur on Mac,but occurs on Windows.

I think this issue is occurred by Default encoding.

Default macOS file encoding is UTF-8. But Default Windows file encoding is not UTF-8.

Juichi Ninomae
Visitor II
April 8, 2018
Posted on April 08, 2018 at 11:41

If you use CubeMX.exe(not Eclipse plugin), The solution is to add the

environment variable in Windows.

Variable name is  _JAVA_OPTIONS .

Variable value is  -Dfile.encoding=UTF-8 .

tyama
Visitor II
August 17, 2018

Hello,

I had the same problem on Windows.

In my environment, following environment variable is effective.

[Variable name] JAVA_TOOL_OPTIONS

[Variable value] -Dfile.encoding=UTF-8