FWStringWrapper
@interface FWStringWrapper : FWObjectWrapper
Undocumented
-
Undocumented
Declaration
Objective-C
FWWrapperCompatible, fw)
-
json字符串解码为Foundation对象
Declaration
Objective-C
- (nullable id)jsonDecode;
Return Value
Foundation对象
-
base64编码
Declaration
Objective-C
- (nullable NSString *)base64Encode;
Return Value
base64字符串
-
base64解码
Declaration
Objective-C
- (nullable NSString *)base64Decode;
Return Value
原字符串
-
计算长度,中文为1,英文为0.5
Declaration
Objective-C
- (NSUInteger)unicodeLength;
-
截取字符串,中文为1,英文为0.5
Declaration
Objective-C
- (nonnull NSString *)unicodeSubstring:(NSUInteger)length;
Parameters
length
截取长度
-
Unicode中文编码,将中文转换成Unicode字符串(如\u7E8C)
Declaration
Objective-C
- (nonnull NSString *)unicodeEncode;
Return Value
Unicode字符串
-
Unicode中文解码,将Unicode字符串(如\u7E8C)转换成中文
Declaration
Objective-C
- (nonnull NSString *)unicodeDecode;
Return Value
中文字符串
-
url参数编码,适用于query参数编码 示例:http://test.com?id=我是中文 => http%3A%2F%2Ftest.com%3Fid%3D%E6%88%91%E6%98%AF%E4%B8%AD%E6%96%87
Declaration
Objective-C
- (nullable NSString *)urlEncodeComponent;
Return Value
url编码字符串
-
url参数解码,适用于query参数解码 示例:http%3A%2F%2Ftest.com%3Fid%3D%E6%88%91%E6%98%AF%E4%B8%AD%E6%96%87 => http://test.com?id=我是中文
Declaration
Objective-C
- (nullable NSString *)urlDecodeComponent;
Return Value
原字符串
-
url编码,适用于整个url编码 示例:http://test.com?id=我是中文 => http://test.com?id=%E6%88%91%E6%98%AF%E4%B8%AD%E6%96%87
Declaration
Objective-C
- (nullable NSString *)urlEncode;
Return Value
url编码地址
-
url解码,适用于整个url解码 示例:http://test.com?id=%E6%88%91%E6%98%AF%E4%B8%AD%E6%96%87 => http://test.com?id=我是中文
Declaration
Objective-C
- (nullable NSString *)urlDecode;
Return Value
原url地址
-
URL参数字符串解码为字典,支持完整URL
Declaration
Objective-C
- (nonnull NSDictionary<NSString *, NSString *> *)queryDecode;
-
md5编码
Declaration
Objective-C
- (nonnull NSString *)md5Encode;
Return Value
md5字符串
-
文件md5编码
Declaration
Objective-C
- (nullable NSString *)md5EncodeFile;
Return Value
md5字符串
-
去掉空白字符
Declaration
Objective-C
@property (nonatomic, copy, readonly) NSString *_Nonnull trimString;
-
首字母大写
Declaration
Objective-C
@property (nonatomic, copy, readonly) NSString *_Nonnull ucfirstString;
-
首字母小写
Declaration
Objective-C
@property (nonatomic, copy, readonly) NSString *_Nonnull lcfirstString;
-
驼峰转下划线
Declaration
Objective-C
@property (nonatomic, copy, readonly) NSString *_Nonnull underlineString;
-
下划线转驼峰
Declaration
Objective-C
@property (nonatomic, copy, readonly) NSString *_Nonnull camelString;
-
过滤JSON解码特殊字符
兼容\uD800-\uDFFF引起JSON解码报错3840问题,不报错时无需调用 规则:只允许以\uD800-\uDBFF高位开头,紧跟\uDC00-\uDFFF低位;其他全不允许 参考:https://github.com/SBJson/SBJson/blob/trunk/Classes/SBJson5StreamTokeniser.m
Declaration
Objective-C
@property (nonatomic, copy, readonly) NSString *_Nonnull escapeJson;
-
转换为UTF8编码数据
Declaration
Objective-C
@property (nonatomic, strong, readonly, nullable) NSData *utf8Data;
-
转换为NSURL
Declaration
Objective-C
@property (nonatomic, copy, readonly, nullable) NSURL *url;
-
转换为NSNumber
Declaration
Objective-C
@property (nonatomic, readonly, nullable) NSNumber *number;
-
从指定位置截取子串
Declaration
Objective-C
- (nullable NSString *)substringFromIndex:(NSInteger)from;
Parameters
from
起始位置
Return Value
子串
-
截取子串到指定位置
Declaration
Objective-C
- (nullable NSString *)substringToIndex:(NSInteger)to;
Parameters
to
结束位置
Return Value
子串
-
截取指定范围的子串
Declaration
Objective-C
- (nullable NSString *)substringWithRange:(NSRange)range;
Parameters
range
指定范围
Return Value
子串
-
计算单行字符串指定字体所占尺寸
Declaration
Objective-C
- (CGSize)sizeWithFont:(nonnull UIFont *)font;
-
计算多行字符串指定字体在指定绘制区域内所占尺寸
Declaration
Objective-C
- (CGSize)sizeWithFont:(nonnull UIFont *)font drawSize:(CGSize)drawSize;
-
计算多行字符串指定字体、指定属性在指定绘制区域内所占尺寸
Declaration
Objective-C
- (CGSize)sizeWithFont:(nonnull UIFont *)font drawSize:(CGSize)drawSize attributes: (nullable NSDictionary<NSAttributedStringKey, id> *)attributes;
-
是否匹配正则表达式,示例:^[a-zA-Z0-9_\u4e00-\u9fa5]{4,14}$
Declaration
Objective-C
- (BOOL)matchesRegex:(nonnull NSString *)regex;
-
快速读取本地化语言
Declaration
Objective-C
@property (nonatomic, copy, readonly) NSString *_Nonnull localized;