Start HTMLEntityDecoded.

This commit is contained in:
Brent Simmons
2024-09-15 14:26:01 -07:00
parent d5a7baf53f
commit f835182bc6

View File

@@ -18,8 +18,8 @@ public final class HTMLEntityDecoder {
while true {
var scannedString = nil
if scanner.scanUpToString("&" intoString: &scannedString) {
var scannedString: NSString? = nil
if scanner.scanUpTo("&", into: &scannedString) {
result.append(scannedString)
}
if scanner.isAtEnd {
@@ -37,7 +37,7 @@ public final class HTMLEntityDecoder {
result.append("&")
scanner.scanLocation = savedScanLocation + 1
}
if scanner.isAtEnd {
break
}
@@ -49,3 +49,43 @@ public final class HTMLEntityDecoder {
return result
}
}
/// Purpose-built version of NSScanner, which has deprecated the parts we want to use.
final class RSScanner {
let string: String
let count: Int
var scanLocation = 0
var isAtEnd {
scanLocation >= count - 1
}
init(string: String) {
self.string = string
self.count = string.count
}
/// Scans up to `characterToFind` and returns the characters up to (and not including) `characterToFind`.
/// - Returns: nil when there were no characters accumulated (next character was `characterToFind` or already at end of string)
func scanUpTo(_ characterToFind: Character) -> String? {
if isAtEnd {
return nil
}
while true {
}
}
private func currentCharacter() -> Character? {
}
private func
}