I\'m trying to calculate the size in bytes of a String in Swift but I don\'t know what the size of a character is; in how many bytes is one coded?
String
Let\'
It all depends on the character encoding, let's suppose UTF8:
let string = "abde" let size = string.utf8.count
Note that not all characters have the same byte size in UTF8. If your string is ASCII, you can assume 1 byte per character.