Skip to content
Snippets Groups Projects
Commit ca3ebbb3 authored by George Nachman's avatar George Nachman
Browse files

Halfwidth katakana voiced and semi-voiced sound marks are not treated as...

Halfwidth katakana voiced and semi-voiced sound marks are not treated as combining marks by Terminal. I don't really know why; my only guess is that japanese text should be rendered monospaced (TextEdit does) but when these marks combine they don't become double-width, so things don't line up as you'd expect. The solution is to force them to be base characters. Issue 6048.
parent c7a08b08
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -1507,12 +1507,40 @@ static TECObjectRef CreateTECConverterForUTF8Variants(TextEncodingVariant varian
if (self.length == 0) {
return;
}
static dispatch_once_t onceToken;
static NSCharacterSet *exceptions;
dispatch_once(&onceToken, ^{
// These characters are forced to be base characters.
exceptions = [[NSCharacterSet characterSetWithCharactersInString:@"\uff9e\uff9f"] retain];
});
CFIndex index = 0;
NSInteger minimumLocation = 0;
NSRange range;
do {
CFRange tempRange = CFStringGetRangeOfComposedCharactersAtIndex((CFStringRef)self, index);
if (tempRange.location < minimumLocation) {
NSInteger diff = minimumLocation - tempRange.location;
tempRange.location += diff;
if (diff > tempRange.length) {
tempRange.length = 0;
} else {
tempRange.length -= diff;
}
}
range = NSMakeRange(tempRange.location, tempRange.length);
if (range.length > 0) {
// CFStringGetRangeOfComposedCharactersAtIndex thinks that U+FF9E and U+FF9F are
// combining marks. Terminal.app and the person in issue 6048 disagree. Prevent them
// from combining.
NSRange rangeOfFirstException = [self rangeOfCharacterFromSet:exceptions
options:NSLiteralSearch
range:range];
if (rangeOfFirstException.location != NSNotFound &&
rangeOfFirstException.location > range.location) {
range.length = rangeOfFirstException.location - range.location;
minimumLocation = NSMaxRange(range);
}
unichar simple = range.length == 1 ? [self characterAtIndex:range.location] : 0;
NSString *complexString = range.length == 1 ? nil : [self substringWithRange:range];
BOOL stop = NO;
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment