Fast is really a strong and spontaneous coding language for macOS, iOS, watchOS and tvOS....

Page 72

Swift

import Cocoa

var unicodeString

= "Dog‟đ&#x;?ś"

println("UTF-8 Codes: ") for code in unicodeString.utf8 { print("\(code) ") }

print("\n")

println("UTF-16 Codes: ") for code in unicodeString.utf16 { print("\(code) ") } When the above code is compiled and executed, it produces the following result: UTF-8 Codes: 68 111 103 226 128 188 240 159 144 182 UTF-16 Codes: 68 111 103 8252 55357 56374

String Functions & Operators Swift supports a wide range of methods and operators related to Strings: S.No 1

Functions/Operators & Purpose isEmpty A Boolean value that determines whether a string is empty or not. hasPrefix(prefix: String)

2

3

Function to check whether a given parameter string exists as a prefix of the string or not.

hasSuffix(suffix: String) Function to check whether a given parameter string exists as a prefix of the string or not.

60


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.