CBOR Swift does not support Unicode languages and to solve this problem you should implement as follows:
In "Extensions" :
public var ascii_bytes: [UInt8] {
// To supporting unicode languages it should return with .utf8 encoding
return self.data(using: .ascii)?.bytes ?? self.data(using: .utf8)!.bytes
}
In "Encoder":
@objc override func encode() -> String {
// To support Unicode languages, the string encoding must be specified before giving the string length
let asciiBytes = self.ascii_bytes
let encodedArray = Encoder.prepareByteArray(major: .major3, measure: asciiBytes.count)
let headerData = Data(bytes: encodedArray).binary_decimal.hex
let strData = Data(bytes: asciiBytes).hexString
return headerData.appending(strData)
}
CBOR Swift does not support Unicode languages and to solve this problem you should implement as follows:
In "Extensions" :
In "Encoder":