Mugurel Mugurel - 5 months ago 18
Swift Question

Swift Read in UTF8 String

I need to read some metadata which can contain French or German characters & accents.

I think that I need to read the metadata as UTF8 String. But being a beginner in Swift and Apple in general I don't know how to do this.

I tried to implement some similar solutions found on stackOverflow but none worked.

What I'm working with:

let firstMeta: MPTimedMetadata = radioPlayer.timedMetadata.first as! MPTimedMetadata
let metaData = firstMeta.value as! String
print(metaData)


There I get


Antonin DvoÅák


instead of


Antonin Dvořák


Any ideas?

Answer

This is a problem in the library, you cannot fix it because the string is already decoded from data.

There is a reason why the whole set of classes was deprecated in iOS 9.

You should use AVPlayerViewController & AVPlayer & AVPlayerItem & AVMetadataItem.

They are solving this issue. Don't use MPMoviePlayerController.

Comments