YouEclipse / steam-box

🎮 Update profile README / pinned gist to contain your Steam playtime leaderboard. 在你的 profile README / pinned gist 上显示你的 steam 游玩时间排行榜。
Apache License 2.0
163 stars 138 forks source link

If the game name contains Chinese, there is a problem with formatting. #3

Closed homurax closed 4 years ago

homurax commented 4 years ago

https://github.com/YouEclipse/steam-box/blob/77b2872e59a6b4aa9444d6ccf1b8e247a058c430/pkg/steambox/box.go#L84

The generated content is not aligned. like this: https://gist.github.com/homurax/c2ca1c7de88d5f83b033aa02fa4a82a1

Should targetLength be obtained by calculation instead of specified?

YouEclipse commented 4 years ago

thanks for the feedback. will fix it later.

YouEclipse commented 4 years ago

https://github.com/YouEclipse/steam-box/commit/0d44a208f4dfa243d91fc7b2606d35e067d42229

the gameName should be showed correctly now. utf8.RuneCountInString is not the space that Chinese character occupied. it's better to calculate the max length before generate lines,maybe will implemnt it in the feature.

现在应该正常了,utf8.RuneCountInString 不能用来计算中文占用的空间。以后再实现根据游戏名字的长度计算。