mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Fix bug in cStringUsingEncoding:
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@21275 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
20519a6f6b
commit
852816f419
2 changed files with 23 additions and 6 deletions
|
@ -1,12 +1,13 @@
|
|||
2005-06-04 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* GSFileHandle.m:
|
||||
* NSFileManager.m:
|
||||
* Source/GSFileHandle.m:
|
||||
* Source/NSFileManager.m:
|
||||
Define _FILE_OFFSET_BITS to be 64 so that, on unix-like systems which
|
||||
support large file handling (>2GB) the large file handling routines
|
||||
are used.
|
||||
* NSTask.m: Try to deal with pipes properly when launching under
|
||||
* Source/NSTask.m: Try to deal with pipes properly when launching under
|
||||
windows.
|
||||
* Source/GSString.m: Fix bug returning unicode string from cString.
|
||||
|
||||
2005-05-21 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
|
|
|
@ -929,7 +929,7 @@ cString_c(GSStr self, NSStringEncoding enc)
|
|||
{
|
||||
return "\0";
|
||||
}
|
||||
if (enc == intEnc)
|
||||
else if (enc == intEnc)
|
||||
{
|
||||
r = (unsigned char*)GSAutoreleasedBuffer(self->_count+1);
|
||||
|
||||
|
@ -939,6 +939,22 @@ cString_c(GSStr self, NSStringEncoding enc)
|
|||
}
|
||||
r[self->_count] = '\0';
|
||||
}
|
||||
else if (enc == NSUnicodeStringEncoding)
|
||||
{
|
||||
unsigned l = 0;
|
||||
|
||||
/*
|
||||
* The external C string encoding is not compatible with the internal
|
||||
* 8-bit character strings ... we must convert from internal format to
|
||||
* unicode and then to the external C string encoding.
|
||||
*/
|
||||
if (GSToUnicode(&r, &l, self->_contents.c, self->_count, intEnc,
|
||||
NSDefaultMallocZone(), GSUniTerminate|GSUniTemporary|GSUniStrict) == NO)
|
||||
{
|
||||
[NSException raise: NSCharacterConversionException
|
||||
format: @"Can't convert to Unicode string."];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unichar *u = 0;
|
||||
|
@ -954,14 +970,14 @@ cString_c(GSStr self, NSStringEncoding enc)
|
|||
NSDefaultMallocZone(), 0) == NO)
|
||||
{
|
||||
[NSException raise: NSCharacterConversionException
|
||||
format: @"Can't convert to/from Unicode string."];
|
||||
format: @"Can't convert to Unicode string."];
|
||||
}
|
||||
if (GSFromUnicode((unsigned char**)&r, &s, u, l, enc,
|
||||
NSDefaultMallocZone(), GSUniTerminate|GSUniTemporary|GSUniStrict) == NO)
|
||||
{
|
||||
NSZoneFree(NSDefaultMallocZone(), u);
|
||||
[NSException raise: NSCharacterConversionException
|
||||
format: @"Can't convert to/from Unicode string."];
|
||||
format: @"Can't convert from Unicode string."];
|
||||
}
|
||||
NSZoneFree(NSDefaultMallocZone(), u);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue