diff --git a/Framework/PCFileCreator.m b/Framework/PCFileCreator.m index e193a1fa..cab96e86 100644 --- a/Framework/PCFileCreator.m +++ b/Framework/PCFileCreator.m @@ -286,6 +286,31 @@ - (BOOL)createFiles:(NSDictionary *)fileList return YES; } +- (NSString *) sanitizeUppercaseFileNameString:(NSString *) input +{ + NSMutableString *sanitizedString = [NSMutableString stringWithCapacity:[input length]]; + + // Create a character set that includes letters, digits, and the underscore character + NSMutableCharacterSet *allowedCharacters = [NSMutableCharacterSet alphanumericCharacterSet]; + [allowedCharacters addCharactersInString:@"_"]; + + for (NSUInteger i = 0; i < [input length]; i++) + { + unichar character = [input characterAtIndex:i]; + + if ([allowedCharacters characterIsMember:character]) + { + [sanitizedString appendFormat:@"%C", character]; + } + else + { + [sanitizedString appendString:@"_"]; + } + } + + return sanitizedString; +} + - (void)replaceTagsInFileAtPath:(NSString *)newFile withProject:(PCProject *)aProject { @@ -297,6 +322,8 @@ - (void)replaceTagsInFileAtPath:(NSString *)newFile NSString *fn = [aFile stringByDeletingPathExtension]; NSRange subRange; + UCfn = [self sanitizeUppercaseFileNameString: UCfn]; + #ifdef WIN32 file = [[NSMutableString stringWithContentsOfFile: newFile encoding: NSUTF8StringEncoding