Hard coded Chinese string in source code becomes random characters when building on UCB

In my source code, I have a hard-coded Chinese string as following:

8410785--1111416--upload_2022-9-2_23-11-15.png

The string itself is used as an output file name (as in 音符重疊報告.txt).

It works as intended in engine and when I compiled the game locally. I was able to output my file both in engine and with my locally compiled game.

However, when I build with UCB, the string becomes random characters when I output it to debug.

I have checked multiple times and can confirm this only happens when the game is built with UCB. This is also not a unique issue. It seems like all hard-coded Chinese strings in the source code get corrupted when compiled via UCB too.

Currently, I changed my file names to be English only as a temporary solution. However, I would like to know why this error happens, because I was unable to find related issues over Google or this forum.

Thank you!

Local Unity Version: 2020.3.38f1
Cloud Unity Version: 2020.3.38f1

I think I’ve seen similar issues before when the source files weren’t encoded in utf-8 format. Might be worth trying that - you can change the encoding using visual studio, notepad2, uniscite etc

Thank you for replying! It seems like a sensible solution. However, I am a bit hesitant to change the entire project encoding style because…I am a bit afraid that it will break the project. I guess for now I will just keep using English only characters in my project.

It shouldn’t break anything, utf-8 supports all characters (including all Chinese/Japanese/Korean etc…) You don’t need to change all your files, you could just change the one you’re having problems with. Alternatively just create a source file for all your string literals and make it utf-8.

3 Likes

Hello,
@WiseyeStudio , I have confirmed with the Unity Cloud devs that encoding the script to UTF-8, by all accounts should fix your issue, as @tonemcbride wrote. Or making on UTF-8 encoded script for such strings.
Also, the devs have confirmed, that changing the encoding of the script is unlikely to break the project.

2 Likes