Created
July 4, 2023 07:30
-
-
Save emonkak/d6f8334261adb4618c5879621a644dd5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/sources/NSStringITerm.m b/sources/NSStringITerm.m | |
index cd32c4ecf..ff996e611 100644 | |
--- a/sources/NSStringITerm.m | |
+++ b/sources/NSStringITerm.m | |
@@ -47,6 +47,7 @@ | |
#import <apr-1/apr_base64.h> | |
#import <Carbon/Carbon.h> | |
#import <wctype.h> | |
+#include <wchar.h> | |
@implementation NSString (iTerm) | |
@@ -57,17 +58,7 @@ | |
+ (BOOL)isDoubleWidthCharacter:(int)unicode | |
ambiguousIsDoubleWidth:(BOOL)ambiguousIsDoubleWidth | |
unicodeVersion:(NSInteger)version { | |
- if (unicode <= 0xa0 || | |
- (unicode > 0x452 && unicode < 0x1100)) { | |
- // Quickly cover the common cases. | |
- return NO; | |
- } | |
- | |
- if ([[NSCharacterSet fullWidthCharacterSetForUnicodeVersion:version] longCharacterIsMember:unicode]) { | |
- return YES; | |
- } | |
- if (ambiguousIsDoubleWidth && | |
- [[NSCharacterSet ambiguousWidthCharacterSetForUnicodeVersion:version] longCharacterIsMember:unicode]) { | |
+ if (wcwidth(unicode) >= 2) { | |
return YES; | |
} | |
return NO; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment