mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +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
553d92634d
commit
63e6d7bba3
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>
|
2001-09-27 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSString: setupQuotables() ... add several characters to the
|
* Source/NSString: setupQuotables() ... add several characters to the
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include <Foundation/NSProcessInfo.h>
|
#include <Foundation/NSProcessInfo.h>
|
||||||
#include <Foundation/NSLock.h>
|
#include <Foundation/NSLock.h>
|
||||||
#include <Foundation/NSAutoreleasePool.h>
|
#include <Foundation/NSAutoreleasePool.h>
|
||||||
|
#include <Foundation/NSData.h>
|
||||||
|
|
||||||
#ifdef HAVE_SYSLOG_H
|
#ifdef HAVE_SYSLOG_H
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
@ -41,12 +42,29 @@
|
||||||
static void
|
static void
|
||||||
_NSLog_standard_printf_handler (NSString* message)
|
_NSLog_standard_printf_handler (NSString* message)
|
||||||
{
|
{
|
||||||
unsigned len = [message cStringLength];
|
NSData *d;
|
||||||
char buf[len+1];
|
const char *buf;
|
||||||
|
unsigned len;
|
||||||
|
|
||||||
[message getCString: buf];
|
d = [message dataUsingEncoding: NSASCIIStringEncoding
|
||||||
buf[len] = '\0';
|
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
|
#ifdef HAVE_SYSLOG
|
||||||
|
|
||||||
if (write(2, buf, len) != len)
|
if (write(2, buf, len) != len)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue