summaryrefslogtreecommitdiff
path: root/common/platform_nsstring.mm
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-08-22 12:37:23 +0200
committerKonstantin Käfer <mail@kkaefer.com>2014-08-22 12:37:23 +0200
commit6610a6370b9702d6dbd107716d5df3227be42e39 (patch)
treeaba164719d56404ac757c6eef8cefcbc9d5ae61c /common/platform_nsstring.mm
parentb9c7e1bdd99b4c6d37672ef34ffe178d4bc54ad3 (diff)
downloadqtlocation-mapboxgl-6610a6370b9702d6dbd107716d5df3227be42e39.tar.gz
use platform-specific NSString for case changes on OS X/iOS
refs #309
Diffstat (limited to 'common/platform_nsstring.mm')
-rw-r--r--common/platform_nsstring.mm21
1 files changed, 21 insertions, 0 deletions
diff --git a/common/platform_nsstring.mm b/common/platform_nsstring.mm
new file mode 100644
index 0000000000..9119f2a8fe
--- /dev/null
+++ b/common/platform_nsstring.mm
@@ -0,0 +1,21 @@
+#import <Foundation/Foundation.h>
+
+#include <mbgl/platform/platform.hpp>
+
+namespace mbgl {
+namespace platform {
+
+std::string uppercase(const std::string &string) {
+ NSString *nsstring = [[NSString alloc] initWithBytesNoCopy:const_cast<char *>(string.data()) length:string.size() encoding:NSUTF8StringEncoding freeWhenDone:NO];
+ nsstring = [nsstring uppercaseString];
+ return { [nsstring cStringUsingEncoding:NSUTF8StringEncoding], [nsstring lengthOfBytesUsingEncoding:NSUTF8StringEncoding] };
+}
+
+std::string lowercase(const std::string &string) {
+ NSString *nsstring = [[NSString alloc] initWithBytesNoCopy:const_cast<char *>(string.data()) length:string.size() encoding:NSUTF8StringEncoding freeWhenDone:NO];
+ nsstring = [nsstring lowercaseString];
+ return { [nsstring cStringUsingEncoding:NSUTF8StringEncoding], [nsstring lengthOfBytesUsingEncoding:NSUTF8StringEncoding] };
+}
+
+}
+} \ No newline at end of file