Can't Chinese characters be set for packaging names?

Can’t Chinese characters be set for packaging names? I have tested both Windows and Android platforms and encountered errors during compilation

It’s not about Chinese, to be clear.

The project name can only contain ASCII letters (a-z), digits, underscore or minus sign. No local characters (Chinese, Polish, Greek, Ukrainian…) are allowed. Many other characters are disallowed as well (like # or comma or space).

This requirement has to stay – the project name is used to determine a lot of internal things, in CGE, and in various tooling (also for Windows manifest, also for Android package). These things only allow a limited set of characters. We already have some non-trivial code to allow even minus (-) everywhere, it’s not that obvious :slight_smile:

That being said, the project caption is supposed to be readable for the user, and it dictates a lot of user-visible strings (like application window title on desktop, application name on Android/iOS desktop etc.). And the caption can contain any character (including spaces, commas, any local Chinese or other characters). Note that after changing “caption” in manifest you shall run “Code → Regenerate Project (…)” in editor (or just manually edit castleautogenerated.pas to reflect the same change, for now).

So: Please clarify why you would like to put Chinese characters in the project name. If it’s for the user, to make application caption with Chinese characters visible for the user → put it in caption.

What I mean is that the app name can be set in Chinese, and compiled into an exe name that can also be set by oneself

I haven’t test it, but perhaps “executable_name” is what you are looking for. CastleEngineManifest.xml - Syntax and Examples | Manual | Castle Game Engine

Tested and not allowed to be used

Exception “Exception”:
Project executable_name contains invalid characters: “91M2?ͻ??”, this character is not allowed: “#229

Command finished with status 1.

To have Chinese application name on the Android/iOS screen, set caption, as mentioned in my previous post :slight_smile: The caption determines what is seen there, and it can include any set of characters.

I think we could enable more characters in the executable name, this shall not be a problem. I’ll look into this later today. Any character allowed by the filesystem should be OK there.

Note that ZIP tools have serious limitations on what file names can be packaged. E.g. Windows’ embedded zip simply ignores everything non-ASCII. Linux’s zip library often confuses non-ASCII filenames (and makes them into an unreadable mess) when those were not archived by the same library. 7Zip seems to be the most reliable in extracting such archives, but it’s usually not a good idea to demand end-users to install a better unzipper to handle the downloaded app.

Footnote: since 1991 when I’ve first encountered this problem, naming files using non-ascii symbols (and even some special symbols) is not a good idea, the situation has improved over the years, but not too significantly. Especially in terms of cross-platform filenames, windows-linux-mac (just to mention that Unix filenames can contain symbols like : or \) first of all, but I’m even scared to think of closed systems like Nintendo Switch or Playstation. So, overall, naming a file (be it executable or asset) in a non-ascii (lower 128 chars) way is in general a bad idea.

I enabled executable_name to have various characters, including Chinese. The allowed subset should be good for both Windows and Linux modern filesystems (I looked at filenames - What characters are safe in cross-platform file names for Linux, Windows and OS-X - Super User ).

Testing, I could build + run application with


inside CastleEngineManifest.xml. The sample executable filename 样例中文文本 seems to survive fine packing + unpacking into zip too. Tested on both Linux and Windows, screenshots at the bottom of this post. Debugging from VS Code (using FpDebug) on Linux also is fine.

But please do heed Eugene’s warnings :slight_smile: Using a filename with Chinese characters, while allowed now in Castle Game Engine, is still something that may cause issues with some tools down the line. I surely didn’t test everything possible that people may do with files :slight_smile: You are quite likely saving yourself some future trouble by just using an ASCII name. In the end, the name of your EXE should be internal for users. For Windows, you can create an installer for your application using e.g. InnoSetup, that will create a nice application icon with any caption on the desktop (which is then independent from the exe name).

1 Like

And as usual, the new engine version with these improvements will be automatically available for download on Download | Castle Game Engine once it passes some automatic tests. You can watch this page, when it will no longer show the commit titled " Eliminate UTF8CharacterToUnicode warnings…" then everything is included in the download.

I also took this opportunity to cleanup our CastleUnicode unit API, simplifying some things and added TCastleStringIterator. And added a few new auto-tests to make sure it is OK, also with Chinese characters. So overall the engine is better now, I’m happy :slight_smile:

1 Like

Thank you.

1 Like