NSDictionary `description` formatting problem — treats structure like char data

后端 未结 2 448
谎友^
谎友^ 2020-12-18 00:34

I\'ve got a custom class (which resembles an NSArray in concept and, hopefully, formatted appearance) which has a description formatter.

When the outp

2条回答
  •  别那么骄傲
    2020-12-18 01:23

    This is a wonderful security-related "feature" that was introduced in OS X 10.5+ version of syslog().

    As explained by an Apple engineer in this post: Who broke NSLog on Leopard?,

    That's the behavior of syslog(). From the man page:

    Newlines and other non-printable characters embedded in the message string are printed in an alternate format. This prevents someone from using non-printable characters to construct misleading log messages in an output file. Newlines are printed as "\n", tabs are printed as "\t". Other control characters are printed using a caret ("^") representation, for example "^M" for carriage return.

    The ASL subsystem, which NSLog() writes to, does the same (at least in Leopard). Writing the XML to a file is a reasonable alternative.

    Chris Kane Cocoa Frameworks, Apple

    See man syslog for more info.

提交回复
热议问题