|
6 | 6 |
|
7 | 7 | .. function:: length(s)
|
8 | 8 |
|
| 9 | + ``length(A) -> Integer`` |
| 10 | + |
| 11 | + Returns the number of elements in A |
| 12 | + |
| 13 | + ``length(collection) -> Integer`` |
| 14 | + |
| 15 | + For ordered, indexable collections, the maximum index ``i`` for which ``getindex(collection, i)`` is valid. For unordered collections, the number of elements. |
| 16 | + |
| 17 | + ``length(s)`` |
| 18 | + |
9 | 19 | The number of characters in string ``s``.
|
10 | 20 |
|
11 | 21 | .. function:: sizeof(s::AbstractString)
|
12 | 22 |
|
| 23 | + ``sizeof(type)`` |
| 24 | + |
| 25 | + Size, in bytes, of the canonical binary representation of the given type, if any. |
| 26 | + |
| 27 | + ``sizeof(s::AbstractString)`` |
| 28 | + |
13 | 29 | The number of bytes in string ``s``.
|
14 | 30 |
|
15 | 31 | .. function:: *(s, t)
|
16 | 32 |
|
| 33 | + ``*(A, B)`` |
| 34 | + :noindex: |
| 35 | + |
| 36 | + Matrix multiplication |
| 37 | + |
| 38 | + ``*(x, y...)`` |
| 39 | + |
| 40 | + Multiplication operator. ``x*y*z*...`` calls this function with all arguments, i.e. |
| 41 | + ``*(x, y, z, ...)``. |
| 42 | + |
| 43 | + ``*(s, t)`` |
| 44 | + |
17 | 45 | Concatenate strings. The ``*`` operator is an alias to this function.
|
18 | 46 |
|
19 | 47 | .. doctest::
|
|
23 | 51 |
|
24 | 52 | .. function:: ^(s, n)
|
25 | 53 |
|
| 54 | + ``^(x, y)`` |
| 55 | + |
| 56 | + Exponentiation operator. |
| 57 | + |
| 58 | + ``^(s, n)`` |
| 59 | + |
26 | 60 | Repeat ``n`` times the string ``s``. The ``^`` operator is an alias to this function.
|
27 | 61 |
|
28 | 62 | .. doctest::
|
|
42 | 76 |
|
43 | 77 | Create a string from the address of a C (0-terminated) string encoded in ASCII or UTF-8. A copy is made; the ptr can be safely freed. If ``length`` is specified, the string does not have to be 0-terminated.
|
44 | 78 |
|
| 79 | + ``bytestring(s)`` |
| 80 | + |
| 81 | + Convert a string to a contiguous byte array representation appropriate for passing it to C functions. The string will be encoded as either ASCII or UTF-8. |
| 82 | + |
45 | 83 | .. function:: bytestring(s)
|
46 | 84 |
|
| 85 | + ``bytestring(::Ptr{UInt8}, [length])`` |
| 86 | + |
| 87 | + Create a string from the address of a C (0-terminated) string encoded in ASCII or UTF-8. A copy is made; the ptr can be safely freed. If ``length`` is specified, the string does not have to be 0-terminated. |
| 88 | + |
| 89 | + ``bytestring(s)`` |
| 90 | + |
47 | 91 | Convert a string to a contiguous byte array representation appropriate for passing it to C functions. The string will be encoded as either ASCII or UTF-8.
|
48 | 92 |
|
49 | 93 | .. function:: ascii(::Array{UInt8,1})
|
50 | 94 |
|
51 | 95 | Create an ASCII string from a byte array.
|
52 | 96 |
|
| 97 | + ``ascii(s)`` |
| 98 | + |
| 99 | + Convert a string to a contiguous ASCII string (all characters must be valid ASCII characters). |
| 100 | + |
| 101 | + ``ascii(::Ptr{UInt8}, [length])`` |
| 102 | + |
| 103 | + Create an ASCII string from the address of a C (0-terminated) string encoded in ASCII. A copy is made; the ptr can be safely freed. If ``length`` is specified, the string does not have to be 0-terminated. |
| 104 | + |
53 | 105 | .. function:: ascii(s)
|
54 | 106 |
|
| 107 | + ``ascii(::Array{UInt8,1})`` |
| 108 | + |
| 109 | + Create an ASCII string from a byte array. |
| 110 | + |
| 111 | + ``ascii(s)`` |
| 112 | + |
55 | 113 | Convert a string to a contiguous ASCII string (all characters must be valid ASCII characters).
|
56 | 114 |
|
| 115 | + ``ascii(::Ptr{UInt8}, [length])`` |
| 116 | + |
| 117 | + Create an ASCII string from the address of a C (0-terminated) string encoded in ASCII. A copy is made; the ptr can be safely freed. If ``length`` is specified, the string does not have to be 0-terminated. |
| 118 | + |
57 | 119 | .. function:: ascii(::Ptr{UInt8}, [length])
|
58 | 120 |
|
| 121 | + ``ascii(::Array{UInt8,1})`` |
| 122 | + |
| 123 | + Create an ASCII string from a byte array. |
| 124 | + |
| 125 | + ``ascii(s)`` |
| 126 | + |
| 127 | + Convert a string to a contiguous ASCII string (all characters must be valid ASCII characters). |
| 128 | + |
| 129 | + ``ascii(::Ptr{UInt8}, [length])`` |
| 130 | + |
59 | 131 | Create an ASCII string from the address of a C (0-terminated) string encoded in ASCII. A copy is made; the ptr can be safely freed. If ``length`` is specified, the string does not have to be 0-terminated.
|
60 | 132 |
|
61 | 133 | .. function:: utf8(::Array{UInt8,1})
|
62 | 134 |
|
63 | 135 | Create a UTF-8 string from a byte array.
|
64 | 136 |
|
| 137 | + ``utf8(::Ptr{UInt8}, [length])`` |
| 138 | + |
| 139 | + Create a UTF-8 string from the address of a C (0-terminated) string encoded in UTF-8. A copy is made; the ptr can be safely freed. If ``length`` is specified, the string does not have to be 0-terminated. |
| 140 | + |
| 141 | + ``utf8(s)`` |
| 142 | + |
| 143 | + Convert a string to a contiguous UTF-8 string (all characters must be valid UTF-8 characters). |
| 144 | + |
65 | 145 | .. function:: utf8(::Ptr{UInt8}, [length])
|
66 | 146 |
|
| 147 | + ``utf8(::Array{UInt8,1})`` |
| 148 | + |
| 149 | + Create a UTF-8 string from a byte array. |
| 150 | + |
| 151 | + ``utf8(::Ptr{UInt8}, [length])`` |
| 152 | + |
67 | 153 | Create a UTF-8 string from the address of a C (0-terminated) string encoded in UTF-8. A copy is made; the ptr can be safely freed. If ``length`` is specified, the string does not have to be 0-terminated.
|
68 | 154 |
|
| 155 | + ``utf8(s)`` |
| 156 | + |
| 157 | + Convert a string to a contiguous UTF-8 string (all characters must be valid UTF-8 characters). |
| 158 | + |
69 | 159 | .. function:: utf8(s)
|
70 | 160 |
|
| 161 | + ``utf8(::Array{UInt8,1})`` |
| 162 | + |
| 163 | + Create a UTF-8 string from a byte array. |
| 164 | + |
| 165 | + ``utf8(::Ptr{UInt8}, [length])`` |
| 166 | + |
| 167 | + Create a UTF-8 string from the address of a C (0-terminated) string encoded in UTF-8. A copy is made; the ptr can be safely freed. If ``length`` is specified, the string does not have to be 0-terminated. |
| 168 | + |
| 169 | + ``utf8(s)`` |
| 170 | + |
71 | 171 | Convert a string to a contiguous UTF-8 string (all characters must be valid UTF-8 characters).
|
72 | 172 |
|
73 | 173 | .. function:: normalize_string(s, normalform::Symbol)
|
|
114 | 214 | Returns true if the given value is valid for its type,
|
115 | 215 | which currently can be one of ``Char``, ``ASCIIString``, ``UTF8String``, ``UTF16String``, or ``UTF32String``
|
116 | 216 |
|
| 217 | + ``isvalid(T, value) -> Bool`` |
| 218 | + |
| 219 | + Returns true if the given value is valid for that type. |
| 220 | + Types currently can be ``Char``, ``ASCIIString``, ``UTF8String``, ``UTF16String``, or ``UTF32String`` |
| 221 | + Values for ``Char`` can be of type ``Char`` or ``UInt32`` |
| 222 | + Values for ``ASCIIString`` and ``UTF8String`` can be of that type, or ``Vector{UInt8}`` |
| 223 | + Values for ``UTF16String`` can be ``UTF16String`` or ``Vector{UInt16}`` |
| 224 | + Values for ``UTF32String`` can be ``UTF32String``, ``Vector{Char}`` or ``Vector{UInt32}`` |
| 225 | + |
| 226 | + ``isvalid(str, i)`` |
| 227 | + |
| 228 | + Tells whether index ``i`` is valid for the given string |
| 229 | + |
117 | 230 | .. function:: isvalid(T, value) -> Bool
|
118 | 231 |
|
| 232 | + ``isvalid(value) -> Bool`` |
| 233 | + |
| 234 | + Returns true if the given value is valid for its type, |
| 235 | + which currently can be one of ``Char``, ``ASCIIString``, ``UTF8String``, ``UTF16String``, or ``UTF32String`` |
| 236 | + |
| 237 | + ``isvalid(T, value) -> Bool`` |
| 238 | + |
119 | 239 | Returns true if the given value is valid for that type.
|
120 | 240 | Types currently can be ``Char``, ``ASCIIString``, ``UTF8String``, ``UTF16String``, or ``UTF32String``
|
121 | 241 | Values for ``Char`` can be of type ``Char`` or ``UInt32``
|
122 | 242 | Values for ``ASCIIString`` and ``UTF8String`` can be of that type, or ``Vector{UInt8}``
|
123 | 243 | Values for ``UTF16String`` can be ``UTF16String`` or ``Vector{UInt16}``
|
124 | 244 | Values for ``UTF32String`` can be ``UTF32String``, ``Vector{Char}`` or ``Vector{UInt32}``
|
125 | 245 |
|
| 246 | + ``isvalid(str, i)`` |
| 247 | + |
| 248 | + Tells whether index ``i`` is valid for the given string |
| 249 | + |
126 | 250 | .. function:: is_assigned_char(c) -> Bool
|
127 | 251 |
|
128 | 252 | Returns true if the given char or integer is an assigned Unicode code point.
|
|
249 | 373 |
|
250 | 374 | .. function:: isvalid(str, i)
|
251 | 375 |
|
| 376 | + ``isvalid(value) -> Bool`` |
| 377 | + |
| 378 | + Returns true if the given value is valid for its type, |
| 379 | + which currently can be one of ``Char``, ``ASCIIString``, ``UTF8String``, ``UTF16String``, or ``UTF32String`` |
| 380 | + |
| 381 | + ``isvalid(T, value) -> Bool`` |
| 382 | + |
| 383 | + Returns true if the given value is valid for that type. |
| 384 | + Types currently can be ``Char``, ``ASCIIString``, ``UTF8String``, ``UTF16String``, or ``UTF32String`` |
| 385 | + Values for ``Char`` can be of type ``Char`` or ``UInt32`` |
| 386 | + Values for ``ASCIIString`` and ``UTF8String`` can be of that type, or ``Vector{UInt8}`` |
| 387 | + Values for ``UTF16String`` can be ``UTF16String`` or ``Vector{UInt16}`` |
| 388 | + Values for ``UTF32String`` can be ``UTF32String``, ``Vector{Char}`` or ``Vector{UInt32}`` |
| 389 | + |
| 390 | + ``isvalid(str, i)`` |
| 391 | + |
252 | 392 | Tells whether index ``i`` is valid for the given string
|
253 | 393 |
|
254 | 394 | .. function:: nextind(str, i)
|
|
377 | 517 | making a copy of the data and treating the NUL as a terminator
|
378 | 518 | rather than as part of the string.
|
379 | 519 |
|
380 |
| -.. function:: utf16(::Union{Ptr{UInt16},Ptr{Int16}} [, length]) |
| 520 | + ``utf16(::Union{Ptr{UInt16},Ptr{Int16}} [, length])`` |
381 | 521 |
|
382 | 522 | Create a string from the address of a NUL-terminated UTF-16 string. A copy is made; the pointer can be safely freed. If ``length`` is specified, the string does not have to be NUL-terminated.
|
383 | 523 |
|
384 |
| -.. function:: utf32(s) |
| 524 | +.. function:: utf16(::Union{Ptr{UInt16},Ptr{Int16}} [, length]) |
385 | 525 |
|
386 |
| - Create a UTF-32 string from a byte array, array of ``Char`` or ``UInt32``, or |
387 |
| - any other string type. (Conversions of byte arrays check for a |
388 |
| - byte-order marker in the first four bytes, and do not include it in |
389 |
| - the resulting string.) |
| 526 | + ``utf16(s)`` |
| 527 | + |
| 528 | + Create a UTF-16 string from a byte array, array of ``UInt16``, or |
| 529 | + any other string type. (Data must be valid UTF-16. Conversions of |
| 530 | + byte arrays check for a byte-order marker in the first two bytes, |
| 531 | + and do not include it in the resulting string.) |
390 | 532 |
|
391 |
| - Note that the resulting ``UTF32String`` data is terminated by the NUL |
392 |
| - codepoint (32-bit zero), which is not treated as a character in the |
| 533 | + Note that the resulting ``UTF16String`` data is terminated by the NUL |
| 534 | + codepoint (16-bit zero), which is not treated as a character in the |
393 | 535 | string (so that it is mostly invisible in Julia); this allows the
|
394 | 536 | string to be passed directly to external functions requiring
|
395 | 537 | NUL-terminated data. This NUL is appended automatically by the
|
396 |
| - `utf32(s)` conversion function. If you have a ``Char`` or ``UInt32`` array |
397 |
| - ``A`` that is already NUL-terminated UTF-32 data, then you |
398 |
| - can instead use `UTF32String(A)`` to construct the string without |
| 538 | + `utf16(s)` conversion function. If you have a ``UInt16`` array |
| 539 | + ``A`` that is already NUL-terminated valid UTF-16 data, then you |
| 540 | + can instead use `UTF16String(A)`` to construct the string without |
399 | 541 | making a copy of the data and treating the NUL as a terminator
|
400 | 542 | rather than as part of the string.
|
401 | 543 |
|
| 544 | + ``utf16(::Union{Ptr{UInt16},Ptr{Int16}} [, length])`` |
| 545 | + |
| 546 | + Create a string from the address of a NUL-terminated UTF-16 string. A copy is made; the pointer can be safely freed. If ``length`` is specified, the string does not have to be NUL-terminated. |
| 547 | + |
| 548 | +.. function:: utf32(s) |
| 549 | + |
| 550 | + ``wstring(s)`` |
| 551 | + |
| 552 | + This is a synonym for either ``utf32(s)`` or ``utf16(s)``, |
| 553 | + depending on whether ``Cwchar_t`` is 32 or 16 bits, respectively. |
| 554 | + The synonym ``WString`` for ``UTF32String`` or ``UTF16String`` |
| 555 | + is also provided. |
| 556 | + |
402 | 557 | .. function:: utf32(::Union{Ptr{Char},Ptr{UInt32},Ptr{Int32}} [, length])
|
403 | 558 |
|
404 |
| - Create a string from the address of a NUL-terminated UTF-32 string. A copy is made; the pointer can be safely freed. If ``length`` is specified, the string does not have to be NUL-terminated. |
| 559 | + ``wstring(s)`` |
| 560 | + |
| 561 | + This is a synonym for either ``utf32(s)`` or ``utf16(s)``, |
| 562 | + depending on whether ``Cwchar_t`` is 32 or 16 bits, respectively. |
| 563 | + The synonym ``WString`` for ``UTF32String`` or ``UTF16String`` |
| 564 | + is also provided. |
405 | 565 |
|
406 | 566 | .. function:: wstring(s)
|
407 | 567 |
|
|
410 | 570 | The synonym ``WString`` for ``UTF32String`` or ``UTF16String``
|
411 | 571 | is also provided.
|
412 | 572 |
|
413 |
| - |
|
0 commit comments