File path contains non-ASCII characters

I’ve got problem handling file path with non-ascii characters:

String froot = CharPointer_UTF8("S:/Path with Chinese/中文目录/");
    Array<File> filesToParse = FileSearchPath(froot).findChildFiles(2, true);

And it hit an assert trying to split the path by semicolons of the utf-8 character

1 Like

Have you tried Jules’ suggestion from this post? Embedding unicode string literals in your cpp files

The utf-8 encoding helper can now be found in the Projucer.

1 Like

Those look like XML entities, if you are reading these from a file you have to ensure the entities are decoded back to plain characters.

As a literal you can write it as u8"\u4e2d\u6587" (note the u8 prepended to it, this is an UTF-8 string literal).

Or, if you can ensure all your files are saved as UTF-8 and you will get all compilers used for your project to interpret your file as UTF-8, you can also write u8"中文".

The old school way of spelling out the encoded bytes directly as a plain string literal will also work — "\xe4\xb8\xad\xe6\x96\x87".

1 Like

With the help of utf-8 encoding helper, it works fine now. Thanks!