pavelliavonau / cmakeconverter

This project aims to facilitate the conversion of Visual Studio to CMake projects.
GNU Affero General Public License v3.0
858 stars 109 forks source link

unicode character in vcxproj.filters might get trouble #136

Open Wongboo opened 3 years ago

Wongboo commented 3 years ago

If we have such lines with unicode in vcxproj.filters

<Filter Include="中文Πhappy">
...
<Filter Include="help">
...
<Filter Include="한국어">
...
<Filter Include="にほんご">
...

they will eventually become

source_group("help" FILES ${help})
source_group("中文Πhappy" FILES ${happy})
source_group("한국어" FILES ${})
source_group("にほんご" FILES ${})

As you can see, because cmakeconverter ignore all unicode character, the filter with only unicode character will become variable with no name, eventually cause trouble, such as 한국어, we can fix in two ways:

Wongboo commented 3 years ago

looks like cmake doesn't support variable with unicode name like 한국어, instead of generating ${}, maybe generating ${other char} is better?

pavelliavonau commented 3 years ago

Better rename your symbols to latin words that cmake supports

Wongboo commented 3 years ago

For existing project with loads of unicode variable, It might be hard to change, how about: CMakesLists.txt

source_group("help" FILES ${help})
source_group("中文Πhappy" FILES ${unicode_var1}) # unicode_var1 means 中文Πhappy
source_group("한국어" FILES ${unicode_var2}) # unicode_var2 means 한국어
source_group("にほんご" FILES ${unicode_var3}) # unicode_var1 means にほんご

stdout

info/warning: detect unicode variable "にほんご", rename to unicode_var3
pavelliavonau commented 3 years ago

I don't like Idea of generating names. Considered this from the very beginning. I shall not implement a thing that CMake does not support. You may help CMake to implement it first if you want. I fixed this problem with 33d75594660e746bdec. You should get warning like check conversion "{}" -> "{}"

Have you checked all the warnings before creating this issue?

And renaming is not hard. Just open UI and rename all non latin filters. It's prepearing step for conversion. Then you may convert easily.

Wongboo commented 3 years ago

I find that I may need to reopen this issue, because visual studio under certain default language will generate unicode character forever as they are default choose, the words in English are Source Files, Header Files, Resource Files

Wongboo commented 3 years ago
Language word1 word2 word3
English Source Files Header Files Resource Files
Chinese(Simplified) 源文件 头文件 资源文件
Chinese(Traditional) 原始程式檔 標頭檔 資源檔
Japanese ソースファイル ヘッダーファイル リソースファイル
Korean 원본 파일 헤더 파일 리소스 파일
Wongboo commented 3 years ago

Maybe a map for these words are necessary

pavelliavonau commented 3 years ago

What are you proposing? Translate with cmake-converter?

  1. cmake DOES NOT SUPPORT these symbols.
  2. 4 languages that you've mentioned are not all the unicode languages that might be used. I'm not going to support every translation.
  3. cmake-converter is not a translator. I'm not going to support this anyway. I actually CAN'T SUPPORT this because I don't know these languages.

If you need to convert you may create your own tool that replace unicode at your files with generated latin ones. Convert. Then replace back at CMakeLists.txt to that format that you would like.

Wongboo commented 3 years ago

No, visual studio seems only generate these 3 unicode words for each language(all in my table), just map them to English can fix the problem, no need to translate every unicode word

Wongboo commented 3 years ago

If user use some unicode words, they should fix themselves. But for the words generated by visual studio default setting for these language mode, map them to English, because you can't assume everyone use VS in English mode

Wongboo commented 3 years ago

Source Files, Header Files, Resource Files are predefined logical folders (filters) in vcproj.filter. If you don't use VS in English, VS will translate Source Files, Header Files, Resource Files, for some language like French, it doesn't matter, for some, it does. No need to translate every word, just these three predefined logical filters

pavelliavonau commented 3 years ago

Again. I do not want to check in any translator into cmake-converter codebase. I do not want to implement any "hacky and partial solution". This is partial solution at least because you cannot guarantee that you have the full list of predefined values. Also this is partial solution because it does not cover all languages that have unicode symbols. Since it's partial - I won't implement and support this.

But nice try for hack this for asian users.

Wongboo commented 3 years ago

People can complete this dictionary later on, this need more people's help. This partial dictionary won't even slow down for English users, will bring help to asian language users and actually give a template for other language, This is a partial fix, but the only downside is that it slow down a bit for unicode users, I don't see why don't use it.