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)   
1
  • 1
    newName.data(using: .windowsCP1251)? Commented Apr 24, 2018 at 7:27

1 Answer 1

2

Maybe this is what you looking for:

newDataName = newName.data(using: .windowsCP1251)
Sign up to request clarification or add additional context in comments.

1 Comment

oh yes, thanks, it's works

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.