swiftsocket / SwiftSocket

The easy way to use sockets on Apple platforms
BSD 3-Clause "New" or "Revised" License
1.68k stars 400 forks source link

how can i read data in string formate #214

Open Fareeha-Naz opened 3 years ago

Fareeha-Naz commented 3 years ago

Hi daer! How can i read data in string formate.... tell me any work around bacouse my server is sending back data in string formate... its urgent please please give me responce as soon as possible

martppa commented 2 years ago

Any sort of information you receive is byte formatted. Since a UTF-8 character is 4 bytes in length (32bits), you can turn those bytes into UTF-8 characters. You can do it when creating a string object:

String(bytes: bytes, encoding: .utf8)