support full-width unicode characters #274
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since full-width characters will break the UI, we should detect the visual width of the string using
mb_strwidth
instead ofmb_strlen
.mb_strlen
when you are detecting the string length for word counting.mb_strwidth
when you are detecting the string width on the screen.I replace all the
mb_strlen
intomb_strwidth
because none of them are used to detecting the string length for word counting. They all are used to get the string width on the screen.You may now use this commit to make CJK characters perfectly fit in the dialog. 😃
正體中文:由於
mb_strlen
是用來計算字串中的字元數量而非寬度,因此需將所有計算字串寬度的函數中的實作都改成使用mb_strwidth
才不會造成跑版。現有的mb_strlen
經人工檢視後發現,用途皆為計算寬度而非字數,因此我將該些實作全部從mb_strlen
改成mb_strwidth
,如此 CJK 字元以及其他全型字元將不會造成跑版。