forked from Mirror/wren
Copy editing.
This commit is contained in:
@ -10,8 +10,8 @@ get involved, it's important to understand the distinction.
|
||||
|
||||
In UTF-8, a single Unicode code point (very roughly a single "character") may
|
||||
be encoded as one or more bytes. This means you can't directly index by code
|
||||
point. There's no way to find, say, the fifth code unit in a string without
|
||||
walking the string from the beginning and counting them as you go.
|
||||
point. There's no way to jump directly to, say, the fifth code unit in a string
|
||||
without walking the string from the beginning and counting them as you go.
|
||||
|
||||
Because counting code units is relatively slow, string methods generally index
|
||||
by *byte*, not *code unit*. When you do:
|
||||
@ -28,8 +28,8 @@ on string *return* byte indices too. So, for example, this does what you want:
|
||||
var hPosition = metalBand.indexOf("h")
|
||||
IO.print(metalBand[hPosition]) // "h"
|
||||
|
||||
In general, methods on strings will work in terms of code units if they can do
|
||||
so efficiently, and will otherwise deal in bytes.
|
||||
In general, methods on strings work in terms of code units if they can do so
|
||||
efficiently, and otherwise deal in bytes.
|
||||
|
||||
## Static Methods
|
||||
|
||||
@ -37,12 +37,12 @@ so efficiently, and will otherwise deal in bytes.
|
||||
|
||||
Creates a new string containing the UTF-8 encoding of `codePoint`.
|
||||
|
||||
It is a runtime error if `codePoint` is not an integer between `0` and
|
||||
`0x10ffff`, inclusive.
|
||||
|
||||
:::dart
|
||||
String.fromCodePoint(8225) // "‡"
|
||||
|
||||
It is a runtime error if `codePoint` is not an integer between `0` and
|
||||
`0x10ffff`, inclusive.
|
||||
|
||||
## Methods
|
||||
|
||||
### **byteAt**(index)
|
||||
|
||||
@ -63,7 +63,7 @@ A `\x` followed by two hex digits specifies a single unencoded byte:
|
||||
|
||||
IO.print("\x48\x69\x2e") // "Hi."
|
||||
|
||||
Strings are objects of class [String](core/string.html).
|
||||
Strings are instances of class [String](core/string.html).
|
||||
|
||||
## Ranges
|
||||
|
||||
@ -92,7 +92,7 @@ example:
|
||||
var slice = list[1..3]
|
||||
IO.print(slice) // ["b", "c", "d"]
|
||||
|
||||
Their class is [Range](core/range.html)
|
||||
Their class is [Range](core/range.html).
|
||||
|
||||
## Null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user