@@ -728,16 +728,6 @@ static void ToASCII(const FunctionCallbackInfo<Value>& args) { |
728 | 728 | // Refs: https://github.com/KDE/konsole/blob/8c6a5d13c0/src/konsole_wcwidth.cpp#L101-L223 |
729 | 729 | static int GetColumnWidth(UChar32 codepoint, |
730 | 730 | bool ambiguous_as_full_width = false) { |
731 | | - const auto zero_width_mask = U_GC_CC_MASK | // C0/C1 control code |
732 | | - U_GC_CF_MASK | // Format control character |
733 | | - U_GC_ME_MASK | // Enclosing mark |
734 | | - U_GC_MN_MASK; // Nonspacing mark |
735 | | - if (codepoint != 0x00AD && // SOFT HYPHEN is Cf but not zero-width |
736 | | - ((U_MASK(u_charType(codepoint)) & zero_width_mask) || |
737 | | - u_hasBinaryProperty(codepoint, UCHAR_EMOJI_MODIFIER))) { |
738 | | - return 0; |
739 | | - } |
740 | | - |
741 | 731 | // UCHAR_EAST_ASIAN_WIDTH is the Unicode property that identifies a |
742 | 732 | // codepoint as being full width, wide, ambiguous, neutral, narrow, |
743 | 733 | // or halfwidth. |
@@ -761,6 +751,15 @@ static int GetColumnWidth(UChar32 codepoint, |
761 | 751 | case U_EA_HALFWIDTH: |
762 | 752 | case U_EA_NARROW: |
763 | 753 | default: |
| 754 | + const auto zero_width_mask = U_GC_CC_MASK | // C0/C1 control code |
| 755 | + U_GC_CF_MASK | // Format control character |
| 756 | + U_GC_ME_MASK | // Enclosing mark |
| 757 | + U_GC_MN_MASK; // Nonspacing mark |
| 758 | + if (codepoint != 0x00AD && // SOFT HYPHEN is Cf but not zero-width |
| 759 | + ((U_MASK(u_charType(codepoint)) & zero_width_mask) || |
| 760 | + u_hasBinaryProperty(codepoint, UCHAR_EMOJI_MODIFIER))) { |
| 761 | + return 0; |
| 762 | + } |
764 | 763 | return 1; |
765 | 764 | } |
766 | 765 | } |
|