mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Start HTMLEntityDecoded.
This commit is contained in:
@@ -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
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user