[원본문서 페이지 주소]
https://docs.swift.org/swift-book/LanguageGuide/StringsAndCharacters.html
Strings and Characters — The Swift Programming Language (Swift 5.7)
Strings and Characters A string is a series of characters, such as "hello, world" or "albatross". Swift strings are represented by the String type. The contents of a String can be accessed in various ways, including as a collection of Character values. Swi
docs.swift.org
1. 원본 내용
Strings and Characters
A string is a series of characters, such as "hello, world" or "albatross". Swift strings are represented by the String type. The contents of a String can be accessed in various ways, including as a collection of Character values.
Swift’s String and Character types provide a fast, Unicode-compliant way to work with text in your code. The syntax for string creation and manipulation is lightweight and readable, with a string literal syntax that’s similar to C. String concatenation is as simple as combining two strings with the + operator, and string mutability is managed by choosing between a constant or a variable, just like any other value in Swift. You can also use strings to insert constants, variables, literals, and expressions into longer strings, in a process known as string interpolation. This makes it easy to create custom string values for display, storage, and printing.
Despite this simplicity of syntax, Swift’s String type is a fast, modern string implementation. Every string is composed of encoding-independent Unicode characters, and provides support for accessing those characters in various Unicode representations.
NOTE
Swift’s String type is bridged with Foundation’s NSString class. Foundation also extends String to expose methods defined by NSString. This means, if you import Foundation, you can access those NSString methods on String without casting.
For more information about using String with Foundation and Cocoa, see Bridging Between String and NSString.
2. 한글 번역본
Strings and Characters
문자열은 "hello, world" 또는 "albatross"와 같은 일련의 문자들입니다.Swift 문자열의 타입은 'String'으로 표시됩니다. String의 내용은 Character 값의 컬렉션을 포함하여 다양한 방법으로 액세스할 수 있습니다.
Swift의 'String'과 'Character' 타입은 작성중인 코드에서 텍스트로 작업하는 내용에 있어 빠른 유니코드 호환 방법을 제공합니다. 문자열 생성 및 조작을 위한 구문은 C와 유사한 문자열 리터럴 구문을 사용하여 가볍고 읽기 쉽습니다.
문자열을 연결하는 방법은 두개의 문자열을 '+' 연산자로 결합하는 것처럼 간단하며, 문자열의 mutability는 Swift의 다른 값과 마찬가지로 상수 또는 변수 중에서 선택하여 사용하면 됩니다.
문자열을 사용하여 문자열 보간("\()")이라고 하는 프로세스에서 더 긴 문자열에 상수, 변수, 리터럴 및 표현식을 삽입할 수도 있습니다.
이렇게 하면 화면에 표시하거나, 저장하는 등의 행위에서 사용자 지정 문자열 값을 쉽게 사용하도록 만들 수 있습니다.
let greet : String = "안녕하세요"
var name : Stromg = "홍길동"
print("\(greet), 저의 이름은 \(name) 입니다.")
이렇게 간단한 구문임에도 Swift의 String 타입은 빠르고, 최신 문자열을 구현합니다. 모든 문자열은 인코딩에 독립적인 유니코드 문자로 구성되며, 다양한 유니코드 표현으로 해당 문자에 액세스할 수 있도록 지원합니다.
메모
Swift의 String 유형은 Foundation의 NSString 클래스와 연결됩니다. Foundation 또한 NSString에 의해 정의된 메소드를 나타내기 위해 String을 확장한 것입니다. 즉, Foundation을 가져오면(import) 형변환을하지 않고 String에서 해당 NSString 메서드에 액세스할 수 있습니다.
Foundation 및 Cocoa와 함께 문자열을 사용하는 방법에 대한 자세한 내용은 해당 링크에서 "Bridging Between String and NSString."을 참조하세요.
3. 모르는 단어 정리
- concatenation : 연결 | 연쇄
- mutability : 변하기 쉬움
- casting : 형변환
'영어공부' 카테고리의 다른 글
[영한번역] Swift 공식문서 번역(About Swift) (0) | 2022.10.04 |
---|---|
[영한번역] Swift 공식문서 번역(메인) (1) | 2022.09.21 |