diff --git a/LZStringTool-MacOS/LZString Convert Tool.alfredworkflow b/LZStringTool-MacOS/LZString Convert Tool.alfredworkflow new file mode 100644 index 0000000..7bf47aa Binary files /dev/null and b/LZStringTool-MacOS/LZString Convert Tool.alfredworkflow differ diff --git a/LZStringTool-MacOS/LZStringTool b/LZStringTool-MacOS/LZStringTool new file mode 100755 index 0000000..b1f3a3a Binary files /dev/null and b/LZStringTool-MacOS/LZStringTool differ diff --git a/LZStringTool-MacOS/LZStringTool-MacOS/LZStringObjc.h b/LZStringTool-MacOS/LZStringTool-MacOS/LZStringObjc.h new file mode 100644 index 0000000..c4315b8 --- /dev/null +++ b/LZStringTool-MacOS/LZStringTool-MacOS/LZStringObjc.h @@ -0,0 +1,39 @@ +// +// LZStringObjc.h +// Demo +// +// Created by 王贵彬 on 2022/11/4. +// + +#import +#define WrapStr(...) [[NSString alloc] initWithCString:#__VA_ARGS__ encoding:NSUTF8StringEncoding] + +NS_ASSUME_NONNULL_BEGIN + +@interface LZStringObjc : NSObject + ++ (LZStringObjc *)sharedInstance; + +- (NSString *)compressToBase64:(NSString *)str; +- (NSString *)decompressFromBase64:(NSString *)str; + + +- (NSString *)compressToUTF16:(NSString *)str; +- (NSString *)decompressFromUTF16:(NSString *)str; + + +- (NSArray *)compressToUint8Array:(NSString *)str; +- (NSString *)decompressFromUint8Array:(NSArray *)strArr; + + +- (NSString *)compressToEncodedURIComponent:(NSString *)str; +- (NSString *)decompressFromEncodedURIComponent:(NSString *)str; + + +- (NSString *)compress:(NSString *)str; +- (NSString *)decompress:(NSString *)str; + + +@end + +NS_ASSUME_NONNULL_END diff --git a/LZStringTool-MacOS/LZStringTool-MacOS/LZStringObjc.m b/LZStringTool-MacOS/LZStringTool-MacOS/LZStringObjc.m new file mode 100644 index 0000000..6849bb1 --- /dev/null +++ b/LZStringTool-MacOS/LZStringTool-MacOS/LZStringObjc.m @@ -0,0 +1,655 @@ +// +// LZStringObjc.m +// Demo +// +// Created by 王贵彬 on 2022/11/4. +// + +#import "LZStringObjc.h" +#import + +@interface LZStringObjc () + +@property (nonatomic, strong) JSContext *context; + +@end + +@implementation LZStringObjc + ++ (LZStringObjc *)sharedInstance{ + static LZStringObjc *_instance = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _instance = [[self alloc] init]; + }); + return _instance; +} + ++ (NSString *)JSCode{ + return WrapStr( + // Copyright (c) 2013 Pieroxy + // This work is free. You can redistribute it and/or modify it + // under the terms of the WTFPL, Version 2 + // For more information see LICENSE.txt or http://www.wtfpl.net/ + // + // For more information, the home page: + // http://pieroxy.net/blog/pages/lz-string/testing.html + // + // LZ-based compression algorithm, version 1.4.4 + var LZString = (function() { + + // private property + var f = String.fromCharCode; + var keyStrBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + var keyStrUriSafe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$"; + var baseReverseDic = {}; + + function getBaseValue(alphabet, character) { + if (!baseReverseDic[alphabet]) { + baseReverseDic[alphabet] = {}; + for (var i=0 ; i>> 8; + buf[i*2+1] = current_value % 256; + } + return buf; + }, + + //decompress from uint8array (UCS-2 big endian format) + decompressFromUint8Array:function (compressed) { + if (compressed===null || compressed===undefined){ + return LZString.decompress(compressed); + } else { + var buf=new Array(compressed.length/2); // 2 bytes per character + for (var i=0, TotalLen=buf.length; i> 1; + } + } else { + value = 1; + for (i=0 ; i> 1; + } + } + context_enlargeIn--; + if (context_enlargeIn == 0) { + context_enlargeIn = Math.pow(2, context_numBits); + context_numBits++; + } + delete context_dictionaryToCreate[context_w]; + } else { + value = context_dictionary[context_w]; + for (i=0 ; i> 1; + } + + + } + context_enlargeIn--; + if (context_enlargeIn == 0) { + context_enlargeIn = Math.pow(2, context_numBits); + context_numBits++; + } + // Add wc to the dictionary. + context_dictionary[context_wc] = context_dictSize++; + context_w = String(context_c); + } + } + + // Output the code for w. + if (context_w !== "") { + if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate,context_w)) { + if (context_w.charCodeAt(0)<256) { + for (i=0 ; i> 1; + } + } else { + value = 1; + for (i=0 ; i> 1; + } + } + context_enlargeIn--; + if (context_enlargeIn == 0) { + context_enlargeIn = Math.pow(2, context_numBits); + context_numBits++; + } + delete context_dictionaryToCreate[context_w]; + } else { + value = context_dictionary[context_w]; + for (i=0 ; i> 1; + } + + + } + context_enlargeIn--; + if (context_enlargeIn == 0) { + context_enlargeIn = Math.pow(2, context_numBits); + context_numBits++; + } + } + + // Mark the end of the stream + value = 2; + for (i=0 ; i> 1; + } + + // Flush the last char + while (true) { + context_data_val = (context_data_val << 1); + if (context_data_position == bitsPerChar-1) { + context_data.push(getCharFromInt(context_data_val)); + break; + } + else context_data_position++; + } + return context_data.join(''); + }, + + decompress: function (compressed) { + if (compressed == null) return ""; + if (compressed == "") return null; + return LZString._decompress(compressed.length, 32768, function(index) { return compressed.charCodeAt(index); }); + }, + + _decompress: function (length, resetValue, getNextValue) { + var dictionary = [], + next, + enlargeIn = 4, + dictSize = 4, + numBits = 3, + entry = "", + result = [], + i, + w, + bits, resb, maxpower, power, + c, + data = {val:getNextValue(0), position:resetValue, index:1}; + + for (i = 0; i < 3; i += 1) { + dictionary[i] = i; + } + + bits = 0; + maxpower = Math.pow(2,2); + power=1; + while (power!=maxpower) { + resb = data.val & data.position; + data.position >>= 1; + if (data.position == 0) { + data.position = resetValue; + data.val = getNextValue(data.index++); + } + bits |= (resb>0 ? 1 : 0) * power; + power <<= 1; + } + + switch (next = bits) { + case 0: + bits = 0; + maxpower = Math.pow(2,8); + power=1; + while (power!=maxpower) { + resb = data.val & data.position; + data.position >>= 1; + if (data.position == 0) { + data.position = resetValue; + data.val = getNextValue(data.index++); + } + bits |= (resb>0 ? 1 : 0) * power; + power <<= 1; + } + c = f(bits); + break; + case 1: + bits = 0; + maxpower = Math.pow(2,16); + power=1; + while (power!=maxpower) { + resb = data.val & data.position; + data.position >>= 1; + if (data.position == 0) { + data.position = resetValue; + data.val = getNextValue(data.index++); + } + bits |= (resb>0 ? 1 : 0) * power; + power <<= 1; + } + c = f(bits); + break; + case 2: + return ""; + } + dictionary[3] = c; + w = c; + result.push(c); + while (true) { + if (data.index > length) { + return ""; + } + + bits = 0; + maxpower = Math.pow(2,numBits); + power=1; + while (power!=maxpower) { + resb = data.val & data.position; + data.position >>= 1; + if (data.position == 0) { + data.position = resetValue; + data.val = getNextValue(data.index++); + } + bits |= (resb>0 ? 1 : 0) * power; + power <<= 1; + } + + switch (c = bits) { + case 0: + bits = 0; + maxpower = Math.pow(2,8); + power=1; + while (power!=maxpower) { + resb = data.val & data.position; + data.position >>= 1; + if (data.position == 0) { + data.position = resetValue; + data.val = getNextValue(data.index++); + } + bits |= (resb>0 ? 1 : 0) * power; + power <<= 1; + } + + dictionary[dictSize++] = f(bits); + c = dictSize-1; + enlargeIn--; + break; + case 1: + bits = 0; + maxpower = Math.pow(2,16); + power=1; + while (power!=maxpower) { + resb = data.val & data.position; + data.position >>= 1; + if (data.position == 0) { + data.position = resetValue; + data.val = getNextValue(data.index++); + } + bits |= (resb>0 ? 1 : 0) * power; + power <<= 1; + } + dictionary[dictSize++] = f(bits); + c = dictSize-1; + enlargeIn--; + break; + case 2: + return result.join(''); + } + + if (enlargeIn == 0) { + enlargeIn = Math.pow(2, numBits); + numBits++; + } + + if (dictionary[c]) { + entry = dictionary[c]; + } else { + if (c === dictSize) { + entry = w + w.charAt(0); + } else { + return null; + } + } + result.push(entry); + + // Add w+entry[0] to the dictionary. + dictionary[dictSize++] = w + entry.charAt(0); + enlargeIn--; + + w = entry; + + if (enlargeIn == 0) { + enlargeIn = Math.pow(2, numBits); + numBits++; + } + + } + } + }; + return LZString; + })(); + + if (typeof define === 'function' && define.amd) { + define(function () { return LZString; }); + } else if( typeof module !== 'undefined' && module != null ) { + module.exports = LZString + } + + ); +} + +- (instancetype)init +{ + self = [super init]; + if (self) { + self.context = [JSContext new]; + NSString *content = [LZStringObjc JSCode]; + if (content) { + [self.context evaluateScript:content]; + } + } + return self; +} + +- (NSString *)compressToBase64:(NSString *)str{ + NSString *script = [NSString stringWithFormat:@"LZString.compressToBase64('%@')",str]; + JSValue *value = [self.context evaluateScript:script]; + return [value toString]; +} + +- (NSString *)decompressFromBase64:(NSString *)str{ + NSString *script = [NSString stringWithFormat:@"LZString.decompressFromBase64('%@')",str]; + JSValue *value = [self.context evaluateScript:script]; + return [value toString]; +} + + +- (NSString *)compressToUTF16:(NSString *)str{ + NSString *script = [NSString stringWithFormat:@"LZString.compressToUTF16('%@')",str]; + JSValue *value = [self.context evaluateScript:script]; + return [value toString]; +} +- (NSString *)decompressFromUTF16:(NSString *)str{ + NSString *script = [NSString stringWithFormat:@"LZString.decompressFromUTF16('%@')",str]; + JSValue *value = [self.context evaluateScript:script]; + return [value toString]; +} + + +- (NSArray *)compressToUint8Array:(NSString *)str{ + NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding]; + NSString *script = [NSString stringWithFormat:@"LZString.compressToUint8Array('%@')",data]; + JSValue *value = [self.context evaluateScript:script]; + return [value toArray]; +} + +- (NSString *)decompressFromUint8Array:(NSArray *)strArr{ + NSString *str = [NSString stringWithFormat:@"[%@]",[strArr componentsJoinedByString:@","]]; + NSString *script = [NSString stringWithFormat:@"LZString.decompressFromUint8Array(%@)",str]; + JSValue *value = [self.context evaluateScript:script]; + NSString *hexStr = [value toString]; + hexStr = [hexStr stringByReplacingOccurrencesOfString:@" " withString:@""]; + hexStr = [hexStr stringByReplacingOccurrencesOfString:@"{" withString:@""]; + hexStr = [hexStr stringByReplacingOccurrencesOfString:@"}" withString:@""]; + NSArray *arr = [hexStr componentsSeparatedByString:@","]; + NSString *bytes = [arr.lastObject componentsSeparatedByString:@"="].lastObject; + NSString *decodeStr = [[NSString alloc] initWithData:[self hexStringToData:bytes] encoding:NSUTF8StringEncoding]; + return decodeStr; +} + + +- (NSString *)compressToEncodedURIComponent:(NSString *)str{ + NSString *script = [NSString stringWithFormat:@"LZString.compressToEncodedURIComponent('%@')",str]; + JSValue *value = [self.context evaluateScript:script]; + return [value toString]; +} +- (NSString *)decompressFromEncodedURIComponent:(NSString *)str{ + NSString *script = [NSString stringWithFormat:@"LZString.decompressFromEncodedURIComponent('%@')",str]; + JSValue *value = [self.context evaluateScript:script]; + return [value toString]; +} + + +- (NSString *)compress:(NSString *)str{ + NSString *script = [NSString stringWithFormat:@"LZString.compress('%@')",str]; + JSValue *value = [self.context evaluateScript:script]; + return [value toString]; +} +- (NSString *)decompress:(NSString *)str{ + NSString *script = [NSString stringWithFormat:@"LZString.decompress('%@')",str]; + JSValue *value = [self.context evaluateScript:script]; + return [value toString]; +} + + +// NSData转十六进制字符串 +- (NSString *)dataToHexString:(NSData *)data { + NSUInteger length = data.length; + NSMutableString *hexStr = [NSMutableString stringWithCapacity:length * 2]; + const unsigned char *byte = data.bytes; + for (int i = 0; i < length; i++, byte++) { + [hexStr appendFormat:@"%02X", *byte]; + } + return hexStr; +} + +// 十六进制字符串转NSData +- (NSData *)hexStringToData:(NSString *)hexStr { + hexStr = [hexStr stringByReplacingOccurrencesOfString:@" " withString:@""]; + hexStr = [hexStr stringByReplacingOccurrencesOfString:@"0x" withString:@""]; + hexStr = [hexStr lowercaseString]; + NSUInteger len = hexStr.length; + if (!len) return nil; + unichar *buf = malloc(sizeof(unichar) * len); + if (!buf) return nil; + [hexStr getCharacters:buf range:NSMakeRange(0, len)]; + + NSMutableData *result = [NSMutableData data]; + unsigned char bytes; + char str[3] = { '\0', '\0', '\0' }; + int i; + for (i = 0; i < len / 2; i++) { + str[0] = buf[i * 2]; + str[1] = buf[i * 2 + 1]; + bytes = strtol(str, NULL, 16); + [result appendBytes:&bytes length:1]; + } + free(buf); + return result; +} + +@end diff --git a/LZStringTool-MacOS/LZStringTool-MacOS/main.m b/LZStringTool-MacOS/LZStringTool-MacOS/main.m new file mode 100644 index 0000000..1910b7a --- /dev/null +++ b/LZStringTool-MacOS/LZStringTool-MacOS/main.m @@ -0,0 +1,122 @@ +// +// main.m +// LZStringTool +// +// Created by 王贵彬 on 2022/11/4. +// + +#import +#import "LZStringObjc.h" + +// 1. 编译之后取出LZStringTool执行 chmod a+x LZStringTool 放到环境变量里去就可以方便使用了 + +int main(int argc, const char * argv[]) { + @autoreleasepool { + + NSString *docStr = WrapStr( + ======= [ 欢迎使用 LZStringTool ] ==========\n + -h 查看文档\n + -s 传入需要转换的原字符串\n + -c 编码\n + -d 解码 \n + -t 转换类型(base64/utf16/unit8/uri) 默认使用utf16 + 其中unit8类型解码时传递的是数组 类似这样 '1,2,3,4'这样 + \n \n 参考以下示例代码\n + \n LZStringTool -v + \n LZStringTool -h + \n LZStringTool -e -t 'base64' -s 'hello' + \n LZStringTool -d -t 'base64' -s 'BYUwNmD2Q===' + \n LZStringTool -e -t 'utf16' -s 'hello' + \n LZStringTool -d -t 'utf16' -s 'ˢ䰭䰾搠' + \n ./LZStringTool -e -t 'unit8' -s 'hello' + \n ./LZStringTool -d -t 'unit8' -s '55,129,176,166,7,96,230,2,224,22,0,32,47,2,10,192,26,4,8,192,158,51,0,206,200,32,3,0,30,1,176,1,193,106,20,12,96,197,1,152,11,228,0,0' + \n ./LZStringTool -e -t 'uri' -s 'hello' + \n ./LZStringTool -d -t 'uri' -s 'BYUwNmD2Q' + \n ./LZStringTool -e -s 'hello' + \n ./LZStringTool -d -s 'օ〶惶䀀' + \n ============================================= +); + + + NSMutableString *args = [NSMutableString string]; + for(int i = 0; i < argc; i++){ + [args appendString:[NSString stringWithCString:argv[i] encoding:NSUTF8StringEncoding]]; + [args appendString:@","]; + } + if(argc <= 1){ + puts([docStr UTF8String]); + return 0; + } + + if ([args containsString:@"-v"]) { + puts("v1.0.0"); + return 0; + } + + if ([args containsString:@"-h"]) { + puts([docStr UTF8String]); + return 0; + } + + LZStringObjc *LZ = [LZStringObjc sharedInstance]; + BOOL isEncode = [args containsString:@"-e"]; + BOOL isDecode = [args containsString:@"-d"]; + NSString *type = [[NSUserDefaults standardUserDefaults] stringForKey:@"t"]; + NSString *inputStr = [[NSUserDefaults standardUserDefaults] stringForKey:@"s"]; + if ([type isEqualToString:@"base64"]) { + if(isEncode){ + puts([LZ compressToBase64:inputStr].UTF8String); + } + if(isDecode){ + puts([LZ decompressFromBase64:inputStr].UTF8String); + } + return 0; + } + if ([type isEqualToString:@"utf16"]) { + if(isEncode){ + puts([LZ compressToUTF16:inputStr].UTF8String); + } + if(isDecode){ + puts([LZ decompressFromUTF16:inputStr].UTF8String); + } + return 0; + } + + if ([type isEqualToString:@"uri"]) { + if(isEncode){ + puts([LZ compressToEncodedURIComponent:inputStr].UTF8String); + } + if(isDecode){ + puts([LZ decompressFromEncodedURIComponent:inputStr].UTF8String); + } + return 0; + } + + if ([type isEqualToString:@"unit8"]) { + if(isEncode){ + NSArray *arr = [LZ compressToUint8Array:inputStr]; + puts([arr componentsJoinedByString:@","].UTF8String); + } + if(isDecode){ + NSArray *inputArr = [inputStr componentsSeparatedByString:@","]; + puts([LZ decompressFromUint8Array:inputArr].UTF8String); + } + return 0; + } + + if(!type || type.length == 0){ + if(isEncode){ + puts([LZ compress:inputStr].UTF8String); + } + + if(isDecode){ + puts([LZ decompress:inputStr].UTF8String); + } + return 0; + } + + puts("入参错误,请参考文档:\n"); + puts([docStr UTF8String]); + } + return 0; +} diff --git a/LZStringTool-MacOS/LZStringTool.xcodeproj/project.pbxproj b/LZStringTool-MacOS/LZStringTool.xcodeproj/project.pbxproj new file mode 100644 index 0000000..317760f --- /dev/null +++ b/LZStringTool-MacOS/LZStringTool.xcodeproj/project.pbxproj @@ -0,0 +1,284 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + objects = { + +/* Begin PBXBuildFile section */ + CA029FC7291560B4006C81B9 /* LZStringObjc.m in Sources */ = {isa = PBXBuildFile; fileRef = CA029FC4291560B4006C81B9 /* LZStringObjc.m */; }; + CA029FC8291560B4006C81B9 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = CA029FC5291560B4006C81B9 /* main.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9519C14E291507A400DDFC43 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 9519C150291507A400DDFC43 /* LZStringTool */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = LZStringTool; sourceTree = BUILT_PRODUCTS_DIR; }; + CA029FC4291560B4006C81B9 /* LZStringObjc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LZStringObjc.m; sourceTree = ""; }; + CA029FC5291560B4006C81B9 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + CA029FC6291560B4006C81B9 /* LZStringObjc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LZStringObjc.h; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 9519C14D291507A400DDFC43 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9519C147291507A400DDFC43 = { + isa = PBXGroup; + children = ( + CA029FC3291560B4006C81B9 /* LZStringTool-MacOS */, + 9519C151291507A400DDFC43 /* Products */, + ); + sourceTree = ""; + }; + 9519C151291507A400DDFC43 /* Products */ = { + isa = PBXGroup; + children = ( + 9519C150291507A400DDFC43 /* LZStringTool */, + ); + name = Products; + sourceTree = ""; + }; + CA029FC3291560B4006C81B9 /* LZStringTool-MacOS */ = { + isa = PBXGroup; + children = ( + CA029FC6291560B4006C81B9 /* LZStringObjc.h */, + CA029FC4291560B4006C81B9 /* LZStringObjc.m */, + CA029FC5291560B4006C81B9 /* main.m */, + ); + path = "LZStringTool-MacOS"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 9519C14F291507A400DDFC43 /* LZStringTool */ = { + isa = PBXNativeTarget; + buildConfigurationList = 9519C157291507A400DDFC43 /* Build configuration list for PBXNativeTarget "LZStringTool" */; + buildPhases = ( + 9519C14C291507A400DDFC43 /* Sources */, + 9519C14D291507A400DDFC43 /* Frameworks */, + 9519C14E291507A400DDFC43 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = LZStringTool; + productName = LZStringTool; + productReference = 9519C150291507A400DDFC43 /* LZStringTool */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 9519C148291507A400DDFC43 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastUpgradeCheck = 1400; + TargetAttributes = { + 9519C14F291507A400DDFC43 = { + CreatedOnToolsVersion = 14.0.1; + }; + }; + }; + buildConfigurationList = 9519C14B291507A400DDFC43 /* Build configuration list for PBXProject "LZStringTool" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 9519C147291507A400DDFC43; + productRefGroup = 9519C147291507A400DDFC43; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 9519C14F291507A400DDFC43 /* LZStringTool */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 9519C14C291507A400DDFC43 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + CA029FC8291560B4006C81B9 /* main.m in Sources */, + CA029FC7291560B4006C81B9 /* LZStringObjc.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 9519C155291507A400DDFC43 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 12.3; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 9519C156291507A400DDFC43 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 12.3; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + }; + name = Release; + }; + 9519C158291507A400DDFC43 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 9519C159291507A400DDFC43 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 9519C14B291507A400DDFC43 /* Build configuration list for PBXProject "LZStringTool" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9519C155291507A400DDFC43 /* Debug */, + 9519C156291507A400DDFC43 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 9519C157291507A400DDFC43 /* Build configuration list for PBXNativeTarget "LZStringTool" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9519C158291507A400DDFC43 /* Debug */, + 9519C159291507A400DDFC43 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 9519C148291507A400DDFC43 /* Project object */; +} diff --git a/LZStringTool-MacOS/LZStringTool.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/LZStringTool-MacOS/LZStringTool.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/LZStringTool-MacOS/LZStringTool.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/LZStringTool-MacOS/LZStringTool.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/LZStringTool-MacOS/LZStringTool.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/LZStringTool-MacOS/LZStringTool.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/LZStringTool-MacOS/README.md b/LZStringTool-MacOS/README.md new file mode 100644 index 0000000..6c1c83f --- /dev/null +++ b/LZStringTool-MacOS/README.md @@ -0,0 +1,42 @@ +# Mac 命令行 + +> 练手项目 + +1. 编译好之后,先赋予执行权限 +```bash +chmod a+x LZStringTool + +``` + +2. 调用文档 +```bash +======= [ 欢迎使用 LZStringTool ] ========== + -h 查看文档 + -s 传入需要转换的原字符串 + -c 编码 + -d 解码 + -t 转换类型(base64/utf16/unit8/uri) 默认使用utf16 其中unit8类型解码时传递的是数组 类似这样 '1,2,3,4'这样 + + 参考以下示例代码 + + ./LZStringTool -v # v1.0.0 + ./LZStringTool -h # help文档 + ./LZStringTool -e -t 'base64' -s 'hello' + ./LZStringTool -d -t 'base64' -s 'BYUwNmD2Q===' + ./LZStringTool -e -t 'utf16' -s 'hello' + ./LZStringTool -d -t 'utf16' -s 'ˢ䰭䰾搠' + ./LZStringTool -e -t 'unit8' -s 'hello' + ./LZStringTool -d -t 'unit8' -s '55,129,176,166,7,96,230,2,224,22,0,32,47,2,10,192,26,4,8,192,158,51,0,206,200,32,3,0,30,1,176,1,193,106,20,12,96,197,1,152,11,228,0,0' + ./LZStringTool -e -t 'uri' -s 'hello' + ./LZStringTool -d -t 'uri' -s 'BYUwNmD2Q' + ./LZStringTool -e -s 'hello' + ./LZStringTool -d -s 'օ〶惶䀀' + ============================================= + +``` + + + +3. 利用这个命令行顺手编了个`Alfred workflow` + +​ ![](./example.png) \ No newline at end of file diff --git a/LZStringTool-MacOS/example.png b/LZStringTool-MacOS/example.png new file mode 100644 index 0000000..d28f36b Binary files /dev/null and b/LZStringTool-MacOS/example.png differ diff --git a/lz-string-objc.podspec b/lz-string-objc.podspec index 4997285..8958832 100644 --- a/lz-string-objc.podspec +++ b/lz-string-objc.podspec @@ -10,10 +10,11 @@ Pod::Spec.new do |s| s.homepage = 'https://github.com/wangguibin1993@gmail.com/lz-string-objc' s.license = { :type => 'MIT', :file => 'LICENSE' } s.author = { 'CoderWGB' => '864562082@qq.com' } - s.source = { :git => 'https://github.com/wangguibin1993@gmail.com/lz-string-objc.git', :tag => s.version.to_s } + s.source = { :git => 'https://github.com/WangGuibin/lz-string-objc.git', :tag => s.version.to_s } s.social_media_url = 'https://twitter.com/06PBEc3aUWS4NSi' s.ios.deployment_target = '10.0' + s.osx.deployment_target = '10.9' s.source_files = 'lz-string-objc/Classes/**/*' end