Created
January 18, 2015 17:37
-
-
Save bithavoc/67bc9d28fe63dbcb8c5a to your computer and use it in GitHub Desktop.
Convert NSString to icu::UnicodeString back and forth
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// NSString+UnicodeString.m | |
// | |
// Created by Johan Hernandez on 1/18/15. | |
// Copyright (c) 2015 Bithavoc.io - All rights reserved. | |
// | |
#import "NSString+UnicodeString.hh" | |
#include <string> | |
@implementation NSString (UnicodeString) | |
+ (NSString*)stringWithUnicodeString:(const icu::UnicodeString&) ustr { | |
std::string str; | |
ustr.toUTF8String(str); | |
return [NSString stringWithUTF8String:str.c_str()]; | |
} | |
+ (NSString*)stringWithStdString:(const std::string&) str { | |
return [NSString stringWithUTF8String:str.c_str()]; | |
} | |
- (icu::UnicodeString) UnicodeString { | |
return icu::UnicodeString(self.UTF8String); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment