Ticket #3262 (closed enhancement: fixed)
Inconsistent "char_width" usage in source
Reported by: | egmont | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 4.8.14 |
Component: | mc-core | Version: | master |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Branch state: | no branch | Votes for changeset: |
Description
In the source code, "char_width" or "cw" usually (especially in the viewer and editor) refers to the UTF-8 encoded byte length, while sometimes (e.g. strutilutf8.c str_utf8_term_char_width()) to the number of the character cells occupied in the terminal.
The former usage is incorrect, misleading, makes it harder to read/write source code. It should be search/replaced to byte_length or something similar. The word "width" should always refer to the number of character cells occupied by the Unicode codepoint, never to the number of bytes required to encode it.
Change History
comment:2 Changed 10 years ago by andrew_b
What about "char_length", the length of character in bytes?
comment:3 follow-up: ↓ 4 Changed 10 years ago by egmont
Sound good. Maybe similary just "cl" where it's "cw" now.
comment:4 in reply to: ↑ 3 Changed 10 years ago by andrew_b
- Blocked By 3265 added
- Milestone changed from Future Releases to 4.8.14
Replying to egmont:
Sound good. Maybe similary just "cl" where it's "cw" now.
I renamed "char_width", "cw", "bytes_consumed" to "char_length" for unification.
This commit is in the 3265_cleanup branch.