2010-10-01 20:54:30 +02:00
|
|
|
/* NSString+MAPIStore.m - this file is part of SOGo
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Inverse inc.
|
|
|
|
*
|
|
|
|
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
|
|
|
*
|
|
|
|
* This file is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2010-10-18 14:57:31 +02:00
|
|
|
* the Free Software Foundation; either version 3, or (at your option)
|
2010-10-01 20:54:30 +02:00
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This file is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <talloc.h>
|
|
|
|
|
2011-07-19 01:47:44 +02:00
|
|
|
#import <Foundation/NSData.h>
|
|
|
|
|
2010-10-01 20:54:30 +02:00
|
|
|
#import "NSString+MAPIStore.h"
|
|
|
|
|
|
|
|
@implementation NSString (MAPIStoreDataTypes)
|
|
|
|
|
|
|
|
- (char *) asUnicodeInMemCtx: (void *) memCtx
|
|
|
|
{
|
2010-10-01 22:35:29 +02:00
|
|
|
char *unicode;
|
2011-07-19 01:47:44 +02:00
|
|
|
NSData *encoded;
|
2010-10-01 20:54:30 +02:00
|
|
|
|
2011-07-27 23:51:00 +02:00
|
|
|
if ([self length] > 0)
|
|
|
|
{
|
|
|
|
encoded = [self dataUsingEncoding: NSUTF8StringEncoding];
|
|
|
|
unicode = talloc_strndup (memCtx, [encoded bytes], [encoded length]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
unicode = talloc_memdup (memCtx, "", 1);
|
2010-10-01 20:54:30 +02:00
|
|
|
|
2010-10-01 22:35:29 +02:00
|
|
|
return unicode;
|
2010-10-01 20:54:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|