Commit 74a0fd29 authored by Alexey.Musinov's avatar Alexey.Musinov

Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop

* 'develop' of https://github.com/ONLYOFFICE/core:
  NSString: + stringWithUtf8Buffer method
parents ce7487a1 95d9d8bc
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
@interface NSString (StringUtils) @interface NSString (StringUtils)
+ (id)stringWithWString:(const std::wstring&)string; + (id)stringWithWString:(const std::wstring&)string;
+ (id)stringWithAString:(const std::string&)string; + (id)stringWithAString:(const std::string&)string;
+ (id)stringWithUtf8Buffer:(const char*)string length:(size_t)len;
+ (NSMutableArray*)stringsArray:(const std::vector<std::wstring>&)sources; + (NSMutableArray*)stringsArray:(const std::vector<std::wstring>&)sources;
- (std::wstring)stdwstring; - (std::wstring)stdwstring;
- (std::string)stdstring; - (std::string)stdstring;
......
...@@ -30,6 +30,17 @@ ...@@ -30,6 +30,17 @@
encoding:CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingUTF8)]; encoding:CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingUTF8)];
} }
+ (id)stringWithUtf8Buffer:(const char*)string length:(size_t)len
{
if (len < 1) {
return @"";
}
return [[NSString alloc] initWithBytes:string
length:len*sizeof(char)
encoding:CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingUTF8)];
}
+ (NSMutableArray*)stringsArray:(const std::vector<std::wstring>&)sources { + (NSMutableArray*)stringsArray:(const std::vector<std::wstring>&)sources {
size_t count = sources.size(); size_t count = sources.size();
NSMutableArray* array = [NSMutableArray arrayWithCapacity:count]; NSMutableArray* array = [NSMutableArray arrayWithCapacity:count];
...@@ -51,4 +62,4 @@ ...@@ -51,4 +62,4 @@
return std::string((char*)data.bytes, data.length); return std::string((char*)data.bytes, data.length);
} }
@end @end
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment