Skip to content

Instantly share code, notes, and snippets.

@bithavoc
Created January 18, 2015 17:37
Show Gist options
  • Save bithavoc/67bc9d28fe63dbcb8c5a to your computer and use it in GitHub Desktop.
Save bithavoc/67bc9d28fe63dbcb8c5a to your computer and use it in GitHub Desktop.

Revisions

  1. @johanfirebase johanfirebase created this gist Jan 18, 2015.
    27 changes: 27 additions & 0 deletions NSString+UnicodeString.mm
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    //
    // 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