We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 5524 - [Patch] Pass NSString to NSLog()
Summary: [Patch] Pass NSString to NSLog()
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.0
Hardware: x86_64 macOS 10.15
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-02-01 04:28 UTC by Hiroyuki Iwatsuki
Modified: 2021-02-01 16:56 UTC (History)
0 users

See Also:


Attachments
Fix to pass NSString to NSLog(). (922 bytes, patch)
2021-02-01 04:28 UTC, Hiroyuki Iwatsuki
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Hiroyuki Iwatsuki 2021-02-01 04:28:29 UTC
Created attachment 4746 [details]
Fix to pass NSString to NSLog().

If you pass the C string directly to NSLog(), it will be garbled with Japanese and probably other language strings, or no log will be output at all.

NSLog("Hello, World!"); // => "Hello, World!"
NSLog("こんにちは、世界!"); // => No output...

Therefore, you need to convert the string to an NSString before passing it to NSLog().

NSString *str = [NSString stringWithUTF8String:"こんにちは、世界!"];
NSLog(@"%@", str); // => "こんにちは、世界!"

Thank you.
Comment 1 Sam Lantinga 2021-02-01 16:56:11 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL/rev/c47106665724