0

I have next:

deviceName = String.init(bytes: temp.prefix(upTo: index), encoding: .windowsCP1251)   

where temp - [UInt8]. My question is: how can I convert this string back to Data?
I'm trying to convert like this:

newDataName = Data(newName.windowsCP1251)   

But result is:

Value of type String has no member windowsCP1251

It is works with converting using utf8, but it shows russian characters incorrect. I need to use windowsCP1251 only:

newDataName = Data(newName.utf8)   
Jayesh Thanki
  • 2,037
  • 2
  • 23
  • 32
Sergey Hleb
  • 152
  • 1
  • 16

1 Answers1

2

Maybe this is what you looking for:

newDataName = newName.data(using: .windowsCP1251)
Tj3n
  • 9,837
  • 2
  • 24
  • 35