godot-git-plugin icon indicating copy to clipboard operation
godot-git-plugin copied to clipboard

Cannot show Chinese correctly

Open jinyangcruise opened this issue 3 years ago • 3 comments

image image

jinyangcruise avatar Jan 08 '23 11:01 jinyangcruise

Same Issue here, using windows 11

dreamtwi avatar Mar 04 '23 09:03 dreamtwi

This appears to be a problem with the encoding assumptions made when reading from the libgit2 library. That library is simply an array of characters. It could be encoded as anything, but probably is encoded as UTF-8. What it is NOT encoded as a 32 bit unicode encoding, which is what godot::String holds internally. The constructor used assumes that it is the char array is 8 bits which is then converted to a 32 bit internal storage (see String::copy_from() in core/string/ustring.cpp).

A reasonable fix is to assume all data from libgit2 is UTF8. This should handle almost everyone, For those that have to have their data stored in another encoding, there would need to be an "encoding" parameter probably at the VCS data level (at the same place the user/password/ssh key are recorded.

I believe that an enhancement should be created for including an "encoding" parameter, and that the current plugin should be updated to assume UTF-8.

I'll create a pull request with the defaulting to UTF-8, but please discuss if this doesn't seem like a good solution.

markeel avatar May 25 '23 03:05 markeel

I think default to UTF-8 willl be good. On the other hand, For those that have to have their data stored in another encoding, there would need to be an "encoding" parameter probably at the VCS data level, what if I have different encoding files, one encoding parameter is not enough for this situation. This remainds me of some software I used before like Ultra Edit, IntelliJ IDEA and so on, they can show charactors well. I guess they can detect file's encoding or do something to transfer different encoding data to one common encoding maybe? But detecting encoding may be complicated.

jinyangcruise avatar May 25 '23 06:05 jinyangcruise

See https://github.com/godotengine/godot-git-plugin/issues/218#issuecomment-1924466413 for a possible solution.

Calinou avatar Mar 28 '24 01:03 Calinou

I closed the out of date pull request and created a new one

markeel avatar Apr 01 '24 20:04 markeel