mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
added XMLStringCopy to properly copy NSStrings as xml strings; use it for setting name
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/branches/nsxml_using_libxml2@34505 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
065ac2bce2
commit
8772885b71
3 changed files with 27 additions and 3 deletions
|
@ -39,10 +39,21 @@
|
|||
*/
|
||||
#define XMLSTRING(X) ((const unsigned char*)[X UTF8String])
|
||||
|
||||
inline static unsigned char *XMLStringCopy(NSString *source)
|
||||
{
|
||||
unsigned int len = [source maximumLengthOfBytesUsingEncoding:NSUTF8StringEncoding] + 1;
|
||||
unsigned char *xmlstr = malloc(len);
|
||||
[source getCString:xmlstr maxLength:len encoding:NSUTF8StringEncoding];
|
||||
return xmlstr;
|
||||
}
|
||||
|
||||
inline static NSString*
|
||||
StringFromXMLString(const unsigned char *bytes, unsigned length)
|
||||
{
|
||||
NSString *str;
|
||||
|
||||
if (bytes == NULL)
|
||||
return @"";
|
||||
|
||||
str = [[NSString alloc] initWithBytes: bytes
|
||||
length: length
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue