Question 9)How to encode and decode emoji in IOS?
Answer:func encode(_ s: String) -> String {
let data = s.data(using: .nonLossyASCII, allowLossyConversion: true)!
return String(data: data, encoding: .utf8)!
}
Note that it encodes all non-ASCII characters as \uNNNN, not only Emojis. Decoding is done by reversing the transformations:
func decode(_ s: String) -> String? {
let data = s.data(using: .utf8)!
return String(data: data, encoding: .nonLossyASCII)
}
Question 8)What is the difference between journaling and creative writing?
Answer:Journalism and creative writing are two opposite ends of the literary rope. Their difference is grounded on the fact that journalism relies heavily on the truth, facts, current events, and knowledge. Creative writing, on the other hand, comprises much on art, fiction, and imagination