diff --git a/ChangeLog b/ChangeLog index 0091ff6ae..f773c792e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,12 +1,13 @@ 2005-06-04 Richard Frith-Macdonald - * 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 diff --git a/Source/GSString.m b/Source/GSString.m index 4fa0c3c1f..6669e8624 100644 --- a/Source/GSString.m +++ b/Source/GSString.m @@ -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); }