aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objc/utils/NSString+MCO.mm
blob: 3d692b760df20d03d1704d1b780f2db5c46428df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//
//  NSString+MCO.m
//  mailcore2
//
//  Created by DINH Viêt Hoà on 1/21/13.
//  Copyright (c) 2013 MailCore. All rights reserved.
//

#import "NSString+MCO.h"

#include "MCString.h"

@implementation NSString (MCO)

+ (NSString *) mco_stringWithMCString:(mailcore::String *)cppString
{
    if (cppString == NULL)
        return nil;
    
    return [NSString stringWithCharacters:(const unichar *) cppString->unicodeCharacters() length:cppString->length()];
}

+ (NSString *) mco_stringWithMCObject:(mailcore::Object *)object
{
    if (object == NULL)
        return nil;
    
    return [NSString mco_stringWithMCString:object->description()];
}

- (mailcore::String *) mco_mcString
{
    const UChar * characters = (const UChar *) [self cStringUsingEncoding:NSUTF16StringEncoding];
    return mailcore::String::stringWithCharacters(characters, (unsigned int) [self length]);
}

@end