scinfu / SwiftSoup

SwiftSoup: Pure Swift HTML Parser, with best of DOM, CSS, and jquery (Supports Linux, iOS, Mac, tvOS, watchOS)
https://scinfu.github.io/SwiftSoup/
MIT License
4.52k stars 345 forks source link

Add mimeName to String.Encoding. #281

Closed jverkoey closed 2 months ago

jverkoey commented 2 months ago

This alternative to displayName is more suitable to the charset attribute because it emits IANA-compatible MIME types or throws an error if the String encoding has no equivalent MIME type.

This is a purely additive change with no behavioral changes. Ideally the current uses of String.Encoding/displayName would be replaced with this new mimeName method in order to generate HTML attributes that are more correct.

Related to https://github.com/scinfu/SwiftSoup/issues/279

aehlke commented 2 months ago

LGTM

Please add a test for this if you can in the future (not sure what is good to test here though, as I'm unfamiliar with this use case)