NetNewsWire/Modules/Parser/Sources/SAX/SAXUtilities.swift
2024-09-09 20:54:42 -07:00

34 lines
677 B
Swift
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// SAXUtilities.swift
//
//
// Created by Brent Simmons on 8/26/24.
//
import Foundation
import libxml2
public func SAXEqualTags(_ localName: XMLPointer, _ tag: ContiguousArray<Int8>) -> Bool {
return tag.withUnsafeBufferPointer { bufferPointer in
let tagCount = tag.count // includes 0 terminator
for i in 0..<tagCount - 1 {
let localNameCharacter = localName[i]
if localNameCharacter == 0 {
return false
}
let tagCharacter = UInt8(tag[i])
if localNameCharacter != tagCharacter {
return false
}
}
// localName might actually be longer  make sure its the same length as tag.
return localName[tagCount - 1] == 0
}
}