Skip to content

Instantly share code, notes, and snippets.

@bananafish911
Created February 11, 2017 14:26
Show Gist options
  • Save bananafish911/e8c93cb1670d83f7ca7f9a67e29943f7 to your computer and use it in GitHub Desktop.
Save bananafish911/e8c93cb1670d83f7ca7f9a67e29943f7 to your computer and use it in GitHub Desktop.
//
// AVMetadataItem with utf8 string (eg. Ukrainian, Russian)
//
import Foundation
import AVFoundation
extension AVMetadataItem {
/// stringValue: ISO-8859-1 → UTF-8
var utf8String: String? {
guard let data = stringValue?.data(using: String.Encoding.isoLatin1, allowLossyConversion: true) else {
return nil
}
return String(data: data as Data, encoding: String.Encoding.utf8)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment