Merge pull request #848 from AlphaWallet/fix-chinese-in-erc721-description-showing-up-as-garbage

Fix: Chinese description in ERC721 token card showing up as garbage
pull/849/head
James Sangalli 6 years ago committed by GitHub
commit 3f51c8e01b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      AlphaWallet/Tokens/ViewModels/OpenSeaNonFungibleTokenCardRowViewModel.swift

@ -186,7 +186,8 @@ struct OpenSeaNonFungibleTokenCardRowViewModel {
var description: NSAttributedString {
let string = tokenHolder.values["description"] as? String ?? ""
let htmlData = string.data(using: .utf8)
//.unicode, not .utf8, otherwise Chinese will turn garbage
let htmlData = string.data(using: .unicode)
let options = [NSAttributedString.DocumentReadingOptionKey.documentType: NSAttributedString.DocumentType.html]
return (try? NSMutableAttributedString(data: htmlData ?? Data(), options: options, documentAttributes: nil)) ?? NSAttributedString(string: string)
}

Loading…
Cancel
Save