Fix for unicode data returned as cstring.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@21199 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2005-05-08 15:07:59 +00:00
parent d5e0804ab0
commit 04bfaf2fb5
3 changed files with 31 additions and 3 deletions

View file

@ -2849,7 +2849,16 @@ handle_printf_atsign (FILE *stream,
format: @"unable to convert to cString"];
}
m = [d mutableCopy];
[m appendBytes: "" length: 1];
if (encoding == NSUnicodeStringEncoding)
{
unichar c = 0;
[m appendBytes: &c length: 2];
}
else
{
[m appendBytes: "" length: 1];
}
AUTORELEASE(m);
return (const char*)[m bytes];
}
@ -2974,6 +2983,10 @@ handle_printf_atsign (FILE *stream,
if (len > maxLength) len = maxLength;
memcpy(buffer, [d bytes], len);
if (encoding == NSUnicodeStringEncoding)
{
buffer[len++] = '\0';
}
buffer[len] = '\0';
}