[llvm-bugs] [Bug 47989] New: Clang-format should use UTF-8 character's width shown in editor rather than storage byte size.

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Oct 27 03:06:07 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=47989

            Bug ID: 47989
           Summary: Clang-format should use UTF-8 character's width shown
                    in editor rather than storage byte size.
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: panzhongxian at 126.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

When I input some UTF-8 character rather than simple ASCII, I find that
clang-format will take the character's length as how many bytes expressed,
rather than as the length show in terminal.

For example:

`测` is stored in 3 bytes, but it takes 2 ASCII space in vim or other editors.

The expected formatted code should be as follow:

#define test   \
  /* 测试 */   \
  "aa"         \
  "bb"         \
  "bb"

But what I really get is as follow:

#define test   \
  /* 测试 */ \
  "aa"         \
  "bb"         \
  "bb"

I have tryed both clang-format 11.0.0 and the newest 12.0.0.

I think the width on screen should be used instead of its storage byte size.(Or
is there any configuration to control this?)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201027/d53c291d/attachment.html>


More information about the llvm-bugs mailing list