Skip to content
This repository was archived by the owner on Feb 2, 2022. It is now read-only.

Commit e41d930

Browse files
authored
Merge pull request #58 from nodes-ios/fix/html-string-characterEncoding
Added an option for html string attributes string to fix encoding issues
2 parents 92f06f4 + 30d193e commit e41d930

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

Codemine.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,7 @@
10321032
PRODUCT_NAME = "$(TARGET_NAME)";
10331033
SKIP_INSTALL = YES;
10341034
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
1035-
SWIFT_VERSION = 3.0;
1035+
SWIFT_VERSION = 4.0;
10361036
};
10371037
name = Debug;
10381038
};
@@ -1052,7 +1052,7 @@
10521052
PRODUCT_NAME = "$(TARGET_NAME)";
10531053
SKIP_INSTALL = YES;
10541054
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
1055-
SWIFT_VERSION = 3.0;
1055+
SWIFT_VERSION = 4.0;
10561056
};
10571057
name = Release;
10581058
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

Codemine/Extensions/String+HTML.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ public func stringFromHtml(string: String) -> NSAttributedString? {
1313
let data = string.data(using: String.Encoding.utf8, allowLossyConversion: true)
1414
if let d = data {
1515
let str = try NSAttributedString(data: d,
16-
options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType],
16+
options: [
17+
NSAttributedString.DocumentReadingOptionKey.documentType: NSAttributedString.DocumentType.html,
18+
NSAttributedString.DocumentReadingOptionKey.characterEncoding: String.Encoding.utf8.rawValue],
1719
documentAttributes: nil)
1820
return str
1921
}

0 commit comments

Comments
 (0)