Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

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

Discussion in 'Unity Build Automation' started by Developer1999-1, Sep 2, 2022.

  1. Developer1999-1

    Developer1999-1

    Joined:
    Oct 27, 2020
    Posts:
    35
    In my source code, I have a hard-coded Chinese string as following:

    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.
    upload_2022-9-2_23-14-29.png

    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
     
    Last edited: Sep 5, 2022
  2. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,077
    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
     
  3. Developer1999-1

    Developer1999-1

    Joined:
    Oct 27, 2020
    Posts:
    35
    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.
     
  4. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,077
    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.
     
  5. Carl_UnityDSE

    Carl_UnityDSE

    Unity Technologies

    Joined:
    May 25, 2022
    Posts:
    54
    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.
     
    Developer1999-1 and tonemcbride like this.