Skip to content

Commit 6e51652

Browse files
authored
Merge pull request #214 from hamishknight/log-encoding
Ensure macOS logging uses UTF-8
2 parents d873f38 + 145b923 commit 6e51652

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/Support/Logging-Mac.mm

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
#import <Foundation/Foundation.h>
1717

1818
void IndexStoreDB::Log_impl(const char *loggerName, const char *message) {
19-
// Using NSLog instead of stderr, to avoid interleaving with other log output in the process.
20-
// NSLog also logs to asl.
21-
NSLog(@"%s: %s", loggerName, message);
19+
// Using NSLog instead of stderr, to avoid interleaving with other log output
20+
// in the process. NSLog also logs to asl. Note that we need to print as an
21+
// NSString here, since printing the C string with '%s' would use the default
22+
// system encoding instead of UTF-8.
23+
NSLog(@"%s: %@", loggerName, [NSString stringWithUTF8String:message]);
2224
}
2325

2426
#endif

0 commit comments

Comments
 (0)