mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
Output UTF8 in log messages.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@11074 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
796dcacd54
commit
b62b3a38f6
2 changed files with 27 additions and 4 deletions
|
@ -1,3 +1,8 @@
|
|||
2001-10-02 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSLog.m: _NSLog_standard_printf_handler() modified to output
|
||||
message as UTF8 data if it can't be done as ASCII
|
||||
|
||||
2001-09-27 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSString: setupQuotables() ... add several characters to the
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <Foundation/NSProcessInfo.h>
|
||||
#include <Foundation/NSLock.h>
|
||||
#include <Foundation/NSAutoreleasePool.h>
|
||||
#include <Foundation/NSData.h>
|
||||
|
||||
#ifdef HAVE_SYSLOG_H
|
||||
#include <syslog.h>
|
||||
|
@ -41,12 +42,29 @@
|
|||
static void
|
||||
_NSLog_standard_printf_handler (NSString* message)
|
||||
{
|
||||
unsigned len = [message cStringLength];
|
||||
char buf[len+1];
|
||||
NSData *d;
|
||||
const char *buf;
|
||||
unsigned len;
|
||||
|
||||
[message getCString: buf];
|
||||
buf[len] = '\0';
|
||||
d = [message dataUsingEncoding: NSASCIIStringEncoding
|
||||
allowLossyConversion: NO];
|
||||
if (d == nil)
|
||||
{
|
||||
d = [message dataUsingEncoding: NSUTF8StringEncoding
|
||||
allowLossyConversion: NO];
|
||||
}
|
||||
|
||||
if (d == nil) // Should never happen.
|
||||
{
|
||||
buf = [message lossyCString];
|
||||
len = strlen(buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
buf = (const char*)[d bytes];
|
||||
len = [d length];
|
||||
}
|
||||
|
||||
#ifdef HAVE_SYSLOG
|
||||
|
||||
if (write(2, buf, len) != len)
|
||||
|
|
Loading…
Reference in a new issue