How to convert byte array to string in swift

1 Answer

0 votes
import Foundation

let byteArray: [UInt8] = [65, 114, 97, 103, 111, 114, 110] 

if let string = String(bytes: byteArray, encoding: .utf8) {
    print(string) 
} else {
    print("Failed to decode string")
}



/*
run:

Aragorn

*/

 



answered Jul 12, 2025 by avibootz

Related questions

...