mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
Rewrite -unicodeString method.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@20671 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
3698291b1e
commit
4b20910745
2 changed files with 16 additions and 17 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2005-02-08 11:20 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSString.m: (unicodeString) rewrite to conform to coding
|
||||||
|
standards and to be more efficient.
|
||||||
|
|
||||||
2005-02-08 10:10 Richard Frith-Macdonald <rfm@gnu.org>
|
2005-02-08 10:10 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Tools/gdnc.m: Rewrite startup code to create a daemon using NSTask
|
* Tools/gdnc.m: Rewrite startup code to create a daemon using NSTask
|
||||||
|
|
|
@ -2611,28 +2611,22 @@ handle_printf_atsign (FILE *stream,
|
||||||
/**
|
/**
|
||||||
* Returns a pointer to a null terminated string of 16-bit unichar
|
* Returns a pointer to a null terminated string of 16-bit unichar
|
||||||
* The memory pointed to is not owned by the caller, so the
|
* The memory pointed to is not owned by the caller, so the
|
||||||
* caller must copy its contents to keep it. Raises an
|
* caller must copy its contents to keep it.
|
||||||
*/
|
*/
|
||||||
- (const unichar*) unicharString
|
- (const unichar*) unicharString
|
||||||
{
|
{
|
||||||
NSData *returnData = nil;
|
NSMutableData *data;
|
||||||
int len = [self length];
|
unichar *uniStr;
|
||||||
unichar buf[64];
|
|
||||||
unichar *uniStr = (len < 64) ? buf :
|
|
||||||
NSZoneMalloc(NSDefaultMallocZone(), (len+1) * sizeof(unichar));
|
|
||||||
|
|
||||||
if (uniStr != NULL)
|
|
||||||
{
|
|
||||||
[self getCharacters:uniStr];
|
|
||||||
uniStr[len] = L'\0';
|
|
||||||
returnData = [NSData dataWithBytes:uniStr length:(len+1)*sizeof(unichar)];
|
|
||||||
if (uniStr != buf)
|
|
||||||
NSZoneFree(NSDefaultMallocZone(), uniStr);
|
|
||||||
|
|
||||||
return ((const unichar*)[returnData bytes]);
|
data = [NSMutableData dataWithLength: ([self length] + 1) * sizeof(unichar)];
|
||||||
}
|
uniStr = (unichar*)[data mutableBytes];
|
||||||
return(NULL);
|
if (uniStr != 0)
|
||||||
|
{
|
||||||
|
[self getCharacters: uniStr];
|
||||||
|
}
|
||||||
|
return uniStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a pointer to a null terminated string of 8-bit characters in the
|
* Returns a pointer to a null terminated string of 8-bit characters in the
|
||||||
* default encoding. The memory pointed to is not owned by the caller, so the
|
* default encoding. The memory pointed to is not owned by the caller, so the
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue