Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 66a5b0f

Browse files
committedJun 30, 2015
regenerate the manual
1 parent 7de00ff commit 66a5b0f

18 files changed

+3701
-52
lines changed
 

‎doc/devdocs/cartesian.rst

+3
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ Macro reference
137137
~~~~~~~~~~~~~~~
138138

139139
.. function:: @nloops N itersym rangeexpr bodyexpr
140+
140141
@nloops N itersym rangeexpr preexpr bodyexpr
141142
@nloops N itersym rangeexpr preexpr postexpr bodyexpr
142143

@@ -191,6 +192,7 @@ Macro reference
191192
bounds-checking.
192193

193194
.. function:: @nif N conditionexpr expr
195+
194196
@nif N conditionexpr expr elseexpr
195197

196198
Generates a sequence of ``if ... elseif ... else ... end`` statements. For example::
@@ -200,6 +202,7 @@ Macro reference
200202
would generate::
201203

202204
if i_1 > size(A, 1)
205+
203206
error("Dimension ", 1, " too big")
204207
elseif i_2 > size(A, 2)
205208
error("Dimension ", 2, " too big")

‎doc/stdlib/arrays.rst

+453-1
Large diffs are not rendered by default.

‎doc/stdlib/base.rst

+245-5
Large diffs are not rendered by default.

‎doc/stdlib/c.rst

+31
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,28 @@
9090
on the pointers ``dest`` and ``src`` to ensure that they are valid.
9191
Incorrect usage may corrupt or segfault your program, in the same manner as C.
9292

93+
``unsafe_copy!(dest::Array, do, src::Array, so, N)``
94+
95+
Copy ``N`` elements from a source array to a destination, starting at offset ``so``
96+
in the source and ``do`` in the destination (1-indexed).
97+
98+
The ``unsafe`` prefix on this function indicates that no validation is performed
99+
to ensure that N is inbounds on either array. Incorrect usage may corrupt or segfault
100+
your program, in the same manner as C.
101+
93102
.. function:: unsafe_copy!(dest::Array, do, src::Array, so, N)
94103

104+
``unsafe_copy!(dest::Ptr{T}, src::Ptr{T}, N)``
105+
106+
Copy ``N`` elements from a source pointer to a destination, with no checking. The
107+
size of an element is determined by the type of the pointers.
108+
109+
The ``unsafe`` prefix on this function indicates that no validation is performed
110+
on the pointers ``dest`` and ``src`` to ensure that they are valid.
111+
Incorrect usage may corrupt or segfault your program, in the same manner as C.
112+
113+
``unsafe_copy!(dest::Array, do, src::Array, so, N)``
114+
95115
Copy ``N`` elements from a source array to a destination, starting at offset ``so``
96116
in the source and ``do`` in the destination (1-indexed).
97117

@@ -103,8 +123,19 @@
103123

104124
Copy all elements from collection ``src`` to array ``dest``. Returns ``dest``.
105125

126+
``copy!(dest, do, src, so, N)``
127+
128+
Copy ``N`` elements from collection ``src`` starting at offset ``so``, to
129+
array ``dest`` starting at offset ``do``. Returns ``dest``.
130+
106131
.. function:: copy!(dest, do, src, so, N)
107132

133+
``copy!(dest, src)``
134+
135+
Copy all elements from collection ``src`` to array ``dest``. Returns ``dest``.
136+
137+
``copy!(dest, do, src, so, N)``
138+
108139
Copy ``N`` elements from collection ``src`` starting at offset ``so``, to
109140
array ``dest`` starting at offset ``do``. Returns ``dest``.
110141

‎doc/stdlib/collections.rst

+595-1
Large diffs are not rendered by default.

‎doc/stdlib/dates.rst

+525-2
Large diffs are not rendered by default.

‎doc/stdlib/file.rst

+13-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,18 @@
1313

1414
Set the current working directory.
1515

16+
``cd(f, [dir])``
17+
18+
Temporarily changes the current working directory (HOME if not specified) and applies function f before returning.
19+
1620
.. function:: cd(f, [dir])
1721

22+
``cd(dir::AbstractString)``
23+
24+
Set the current working directory.
25+
26+
``cd(f, [dir])``
27+
1828
Temporarily changes the current working directory (HOME if not specified) and applies function f before returning.
1929

2030
.. function:: readdir([dir]) -> Vector{ByteString}
@@ -112,7 +122,7 @@
112122
.. function:: cp(src::AbstractString, dst::AbstractString; remove_destination::Bool=false, follow_symlinks::Bool=false)
113123

114124
Copy the file, link, or directory from *src* to *dest*.
115-
\"remove_destination=true\" will first remove an existing `dst`.
125+
"remove_destination=true" will first remove an existing `dst`.
116126

117127
If `follow_symlinks=false`, and src is a symbolic link, dst will be created as a symbolic link.
118128
If `follow_symlinks=true` and src is a symbolic link, dst will be a copy of the file or directory
@@ -129,7 +139,7 @@
129139
.. function:: mv(src::AbstractString,dst::AbstractString; remove_destination::Bool=false)
130140

131141
Move the file, link, or directory from *src* to *dest*.
132-
\"remove_destination=true\" will first remove an existing `dst`.
142+
"remove_destination=true" will first remove an existing `dst`.
133143

134144
.. function:: rm(path::AbstractString; recursive=false)
135145

@@ -289,3 +299,4 @@
289299
If the last component of a path contains a dot, split the path into everything
290300
before the dot and everything including and after the dot. Otherwise, return
291301
a tuple of the argument unmodified and the empty string.
302+

‎doc/stdlib/io-network.rst

+469-1
Large diffs are not rendered by default.

‎doc/stdlib/libc.rst

+6-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040

4141
.. function:: time(t::TmStruct)
4242

43-
Converts a ``TmStruct`` struct to a number of seconds since the epoch.
43+
``time()``
44+
45+
Get the system time in seconds since the epoch, with fairly high (typically, microsecond) resolution.
4446

4547
.. function:: strftime([format], time)
4648

@@ -61,9 +63,9 @@
6163

6264
.. function:: msync(ptr, len, [flags])
6365

64-
Forces synchronization of the :func:`mmap`\ ped memory region from ``ptr`` to ``ptr+len``. Flags defaults to ``MS_SYNC``, but can be a combination of ``MS_ASYNC``, ``MS_SYNC``, or ``MS_INVALIDATE``. See your platform man page for specifics. The flags argument is not valid on Windows.
66+
``msync(array)``
6567

66-
You may not need to call ``msync``, because synchronization is performed at intervals automatically by the operating system. However, you can call this directly if, for example, you are concerned about losing the result of a long-running calculation.
68+
Forces synchronization between the in-memory version of a memory-mapped ``Array`` or ``BitArray`` and the on-disk version.
6769

6870
.. data:: MS_ASYNC
6971

@@ -84,3 +86,4 @@
8486
.. function:: munmap(pointer, len)
8587

8688
Low-level interface for unmapping memory (see the man page). With :func:`mmap_array` you do not need to call this directly; the memory is unmapped for you when the array goes out of scope.
89+

‎doc/stdlib/linalg.rst

+552-1
Large diffs are not rendered by default.

‎doc/stdlib/math.rst

+244-12
Large diffs are not rendered by default.

‎doc/stdlib/numbers.rst

+34-2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ Data Formats
5050

5151
.. function:: parse(type, str, [base])
5252

53+
``parse(str, start; greedy=true, raise=true)``
54+
55+
Parse the expression string and return an expression (which could later be passed to eval for execution). Start is the index of the first character to start parsing. If ``greedy`` is true (default), ``parse`` will try to consume as much input as it can; otherwise, it will stop as soon as it has parsed a valid expression. Incomplete but otherwise syntactically valid expressions will return ``Expr(:incomplete, "(error message)")``. If ``raise`` is true (default), syntax errors other than incomplete expressions will raise an error. If ``raise`` is false, ``parse`` will return an expression that will raise an error upon evaluation.
56+
57+
``parse(str; raise=true)``
58+
59+
Parse the whole string greedily, returning a single expression. An error is thrown if there are additional characters after the first expression. If ``raise`` is true (default), syntax errors will raise an error; otherwise, ``parse`` will return an expression that will raise an error upon evaluation.
60+
61+
``parse(type, str, [base])``
62+
5363
Parse a string as a number. If the type is an integer type, then a base can be specified (the default is 10). If the type is a floating point type, the string is parsed as a decimal floating point number.
5464
If the string does not contain a valid number, an error is raised.
5565

@@ -117,7 +127,6 @@ Data Formats
117127

118128
Convert an array of bytes to its hexadecimal representation. All characters are in lower-case. Returns an ASCIIString.
119129

120-
121130
General Number Functions and Constants
122131
--------------------------------------
123132

@@ -279,7 +288,6 @@ General Number Functions and Constants
279288
julia> big"2.1"
280289
2.099999999999999999999999999999999999999999999999999999999999999999999999999986e+00 with 256 bits of precision
281290

282-
283291
.. function:: get_rounding(T)
284292

285293
Get the current floating point rounding mode for type ``T``, controlling
@@ -376,8 +384,31 @@ Integers
376384
julia> isprime(3)
377385
true
378386

387+
``isprime(x::BigInt, [reps = 25]) -> Bool``
388+
389+
Probabilistic primality test. Returns ``true`` if ``x`` is prime; and
390+
``false`` if ``x`` is not prime with high probability. The false positive
391+
rate is about ``0.25^reps``. ``reps = 25`` is considered safe for
392+
cryptographic applications (Knuth, Seminumerical Algorithms).
393+
394+
.. doctest::
395+
396+
julia> isprime(big(3))
397+
true
398+
379399
.. function:: isprime(x::BigInt, [reps = 25]) -> Bool
380400

401+
``isprime(x::Integer) -> Bool``
402+
403+
Returns ``true`` if ``x`` is prime, and ``false`` otherwise.
404+
405+
.. doctest::
406+
407+
julia> isprime(3)
408+
true
409+
410+
``isprime(x::BigInt, [reps = 25]) -> Bool``
411+
381412
Probabilistic primality test. Returns ``true`` if ``x`` is prime; and
382413
``false`` if ``x`` is not prime with high probability. The false positive
383414
rate is about ``0.25^reps``. ``reps = 25`` is considered safe for
@@ -507,3 +538,4 @@ As ``BigInt`` represents unbounded integers, the interval must be specified (e.g
507538
.. function:: randexp!([rng], A::Array{Float64,N})
508539

509540
Fill the array A with random numbers following the exponential distribution (with scale 1).
541+

‎doc/stdlib/parallel.rst

+247-4
Large diffs are not rendered by default.

‎doc/stdlib/pkg.rst

+82
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,23 @@ to use them, you'll need to prefix each function call with an explicit ``Pkg.``,
1515
that path is used in the returned value as ``joinpath(ENV["JULIA_PKGDIR"],"v$(VERSION.major).$(VERSION.minor)")``.
1616
If ``JULIA_PKGDIR`` is a relative path, it is interpreted relative to whatever the current working directory is.
1717

18+
``dir(names...) -> AbstractString``
19+
20+
Equivalent to ``normpath(Pkg.dir(),names...)`` – i.e. it appends path components to the package directory and normalizes the resulting path.
21+
In particular, ``Pkg.dir(pkg)`` returns the path to the package ``pkg``.
22+
1823
.. function:: dir(names...) -> AbstractString
1924

25+
``dir() -> AbstractString``
26+
27+
Returns the absolute path of the package directory.
28+
This defaults to ``joinpath(homedir(),".julia","v$(VERSION.major).$(VERSION.minor)")`` on all platforms
29+
(i.e. ``~/.julia/v0.4`` in UNIX shell syntax). If the ``JULIA_PKGDIR`` environment variable is set, then
30+
that path is used in the returned value as ``joinpath(ENV["JULIA_PKGDIR"],"v$(VERSION.major).$(VERSION.minor)")``.
31+
If ``JULIA_PKGDIR`` is a relative path, it is interpreted relative to whatever the current working directory is.
32+
33+
``dir(names...) -> AbstractString``
34+
2035
Equivalent to ``normpath(Pkg.dir(),names...)`` – i.e. it appends path components to the package directory and normalizes the resulting path.
2136
In particular, ``Pkg.dir(pkg)`` returns the path to the package ``pkg``.
2237

@@ -54,25 +69,59 @@ to use them, you'll need to prefix each function call with an explicit ``Pkg.``,
5469
The package repo is cloned by the name ``pkg`` if provided;
5570
if not provided, ``pkg`` is determined automatically from ``url``.
5671

72+
``clone(pkg)``
73+
74+
If ``pkg`` has a URL registered in ``Pkg.dir("METADATA")``, clone it from that URL on the default branch.
75+
The package does not need to have any registered versions.
76+
5777
.. function:: clone(pkg)
5878

79+
``clone(url, [pkg])``
80+
81+
Clone a package directly from the git URL ``url``.
82+
The package does not need to be a registered in ``Pkg.dir("METADATA")``.
83+
The package repo is cloned by the name ``pkg`` if provided;
84+
if not provided, ``pkg`` is determined automatically from ``url``.
85+
86+
``clone(pkg)``
87+
5988
If ``pkg`` has a URL registered in ``Pkg.dir("METADATA")``, clone it from that URL on the default branch.
6089
The package does not need to have any registered versions.
6190

6291
.. function:: available() -> Vector{ASCIIString}
6392

6493
Returns the names of available packages.
6594

95+
``available(pkg) -> Vector{VersionNumber}``
96+
97+
Returns the version numbers available for package ``pkg``.
98+
6699
.. function:: available(pkg) -> Vector{VersionNumber}
67100

101+
``available() -> Vector{ASCIIString}``
102+
103+
Returns the names of available packages.
104+
105+
``available(pkg) -> Vector{VersionNumber}``
106+
68107
Returns the version numbers available for package ``pkg``.
69108

70109
.. function:: installed() -> Dict{ASCIIString,VersionNumber}
71110

72111
Returns a dictionary mapping installed package names to the installed version number of each package.
73112

113+
``installed(pkg) -> Void | VersionNumber``
114+
115+
If ``pkg`` is installed, return the installed version number, otherwise return ``nothing``.
116+
74117
.. function:: installed(pkg) -> Void | VersionNumber
75118

119+
``installed() -> Dict{ASCIIString,VersionNumber}``
120+
121+
Returns a dictionary mapping installed package names to the installed version number of each package.
122+
123+
``installed(pkg) -> Void | VersionNumber``
124+
76125
If ``pkg`` is installed, return the installed version number, otherwise return ``nothing``.
77126

78127
.. function:: status()
@@ -95,8 +144,19 @@ to use them, you'll need to prefix each function call with an explicit ``Pkg.``,
95144
Pin ``pkg`` at the current version.
96145
To go back to using the newest compatible released version, use ``Pkg.free(pkg)``
97146

147+
``pin(pkg, version)``
148+
149+
Pin ``pkg`` at registered version ``version``.
150+
98151
.. function:: pin(pkg, version)
99152

153+
``pin(pkg)``
154+
155+
Pin ``pkg`` at the current version.
156+
To go back to using the newest compatible released version, use ``Pkg.free(pkg)``
157+
158+
``pin(pkg, version)``
159+
100160
Pin ``pkg`` at registered version ``version``.
101161

102162
.. function:: free(pkg)
@@ -112,8 +172,19 @@ to use them, you'll need to prefix each function call with an explicit ``Pkg.``,
112172

113173
Run the build scripts for all installed packages in depth-first recursive order.
114174

175+
``build(pkgs...)``
176+
177+
Run the build script in "deps/build.jl" for each package in ``pkgs`` and all of their dependencies in depth-first recursive order.
178+
This is called automatically by ``Pkg.resolve()`` on all installed or updated packages.
179+
115180
.. function:: build(pkgs...)
116181

182+
``build()``
183+
184+
Run the build scripts for all installed packages in depth-first recursive order.
185+
186+
``build(pkgs...)``
187+
117188
Run the build script in "deps/build.jl" for each package in ``pkgs`` and all of their dependencies in depth-first recursive order.
118189
This is called automatically by ``Pkg.resolve()`` on all installed or updated packages.
119190

@@ -142,6 +213,17 @@ to use them, you'll need to prefix each function call with an explicit ``Pkg.``,
142213

143214
Run the tests for all installed packages ensuring that each package's test dependencies are installed for the duration of the test. A package is tested by running its ``test/runtests.jl`` file and test dependencies are specified in ``test/REQUIRE``.
144215

216+
``test(pkgs...)``
217+
218+
Run the tests for each package in ``pkgs`` ensuring that each package's test dependencies are installed for the duration of the test. A package is tested by running its ``test/runtests.jl`` file and test dependencies are specified in ``test/REQUIRE``.
219+
145220
.. function:: test(pkgs...)
146221

222+
``test()``
223+
224+
Run the tests for all installed packages ensuring that each package's test dependencies are installed for the duration of the test. A package is tested by running its ``test/runtests.jl`` file and test dependencies are specified in ``test/REQUIRE``.
225+
226+
``test(pkgs...)``
227+
147228
Run the tests for each package in ``pkgs`` ensuring that each package's test dependencies are installed for the duration of the test. A package is tested by running its ``test/runtests.jl`` file and test dependencies are specified in ``test/REQUIRE``.
229+

‎doc/stdlib/profile.rst

+20-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
backtraces.
1616

1717
.. currentmodule:: Base.Profile
18-
1918
The methods in :mod:`Base.Profile` are not exported and need to be called e.g. as ``Profile.print()``.
2019

2120
.. function:: clear()
@@ -32,8 +31,27 @@ The methods in :mod:`Base.Profile` are not exported and need to be called e.g. a
3231
correspond to the same line of code. ``cols`` controls the width
3332
of the display.
3433

34+
``print([io::IO = STDOUT,] data::Vector, lidict::Dict; format = :tree, combine = true, cols = tty_cols())``
35+
36+
Prints profiling results to ``io``. This variant is used to examine
37+
results exported by a previous call to :func:`retrieve`.
38+
Supply the vector ``data`` of backtraces and a dictionary
39+
``lidict`` of line information.
40+
3541
.. function:: print([io::IO = STDOUT,] data::Vector, lidict::Dict; format = :tree, combine = true, cols = tty_cols())
3642

43+
``print([io::IO = STDOUT,] [data::Vector]; format = :tree, C = false, combine = true, cols = tty_cols())``
44+
45+
Prints profiling results to ``io`` (by default, ``STDOUT``). If you
46+
do not supply a ``data`` vector, the internal buffer of accumulated
47+
backtraces will be used. ``format`` can be ``:tree`` or
48+
``:flat``. If ``C==true``, backtraces from C and Fortran code are
49+
shown. ``combine==true`` merges instruction pointers that
50+
correspond to the same line of code. ``cols`` controls the width
51+
of the display.
52+
53+
``print([io::IO = STDOUT,] data::Vector, lidict::Dict; format = :tree, combine = true, cols = tty_cols())``
54+
3755
Prints profiling results to ``io``. This variant is used to examine
3856
results exported by a previous call to :func:`retrieve`.
3957
Supply the vector ``data`` of backtraces and a dictionary
@@ -86,3 +104,4 @@ The methods in :mod:`Base.Profile` are not exported and need to be called e.g. a
86104
(to force JIT-compilation), then call :func:`clear_malloc_data`.
87105
Then execute your command(s) again, quit Julia, and examine the
88106
resulting ``*.mem`` files.
107+

‎doc/stdlib/sort.rst

+10-2
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,18 @@ Sorting Functions
133133

134134
Variant of ``sort!`` that returns a sorted copy of ``v`` leaving ``v`` itself unmodified.
135135

136+
``sort(A, dim, [alg=<algorithm>,] [by=<transform>,] [lt=<comparison>,] [rev=false])``
137+
138+
Sort a multidimensional array ``A`` along the given dimension.
139+
136140
.. function:: sort(A, dim, [alg=<algorithm>,] [by=<transform>,] [lt=<comparison>,] [rev=false])
137141

142+
``sort(v, [alg=<algorithm>,] [by=<transform>,] [lt=<comparison>,] [rev=false])``
143+
144+
Variant of ``sort!`` that returns a sorted copy of ``v`` leaving ``v`` itself unmodified.
145+
146+
``sort(A, dim, [alg=<algorithm>,] [by=<transform>,] [lt=<comparison>,] [rev=false])``
147+
138148
Sort a multidimensional array ``A`` along the given dimension.
139149

140150
.. function:: sortperm(v, [alg=<algorithm>,] [by=<transform>,] [lt=<comparison>,] [rev=false])
@@ -164,7 +174,6 @@ Sorting Functions
164174

165175
Sort the columns of matrix ``A`` lexicographically.
166176

167-
168177
Order-Related Functions
169178
-----------------------
170179

@@ -206,7 +215,6 @@ Order-Related Functions
206215
Variant of ``select!`` which copies ``v`` before partially sorting it, thereby
207216
returning the same thing as ``select!`` but leaving ``v`` unmodified.
208217

209-
210218
Sorting Algorithms
211219
------------------
212220

‎doc/stdlib/strings.rst

+172-13
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,42 @@
66

77
.. function:: length(s)
88

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+
919
The number of characters in string ``s``.
1020

1121
.. function:: sizeof(s::AbstractString)
1222

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+
1329
The number of bytes in string ``s``.
1430

1531
.. function:: *(s, t)
1632

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+
1745
Concatenate strings. The ``*`` operator is an alias to this function.
1846

1947
.. doctest::
@@ -23,6 +51,12 @@
2351

2452
.. function:: ^(s, n)
2553

54+
``^(x, y)``
55+
56+
Exponentiation operator.
57+
58+
``^(s, n)``
59+
2660
Repeat ``n`` times the string ``s``. The ``^`` operator is an alias to this function.
2761

2862
.. doctest::
@@ -42,32 +76,98 @@
4276

4377
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.
4478

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+
4583
.. function:: bytestring(s)
4684

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+
4791
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.
4892

4993
.. function:: ascii(::Array{UInt8,1})
5094

5195
Create an ASCII string from a byte array.
5296

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+
53105
.. function:: ascii(s)
54106

107+
``ascii(::Array{UInt8,1})``
108+
109+
Create an ASCII string from a byte array.
110+
111+
``ascii(s)``
112+
55113
Convert a string to a contiguous ASCII string (all characters must be valid ASCII characters).
56114

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+
57119
.. function:: ascii(::Ptr{UInt8}, [length])
58120

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+
59131
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.
60132

61133
.. function:: utf8(::Array{UInt8,1})
62134

63135
Create a UTF-8 string from a byte array.
64136

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+
65145
.. function:: utf8(::Ptr{UInt8}, [length])
66146

147+
``utf8(::Array{UInt8,1})``
148+
149+
Create a UTF-8 string from a byte array.
150+
151+
``utf8(::Ptr{UInt8}, [length])``
152+
67153
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.
68154

155+
``utf8(s)``
156+
157+
Convert a string to a contiguous UTF-8 string (all characters must be valid UTF-8 characters).
158+
69159
.. function:: utf8(s)
70160

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+
71171
Convert a string to a contiguous UTF-8 string (all characters must be valid UTF-8 characters).
72172

73173
.. function:: normalize_string(s, normalform::Symbol)
@@ -114,15 +214,39 @@
114214
Returns true if the given value is valid for its type,
115215
which currently can be one of ``Char``, ``ASCIIString``, ``UTF8String``, ``UTF16String``, or ``UTF32String``
116216

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+
117230
.. function:: isvalid(T, value) -> Bool
118231

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+
119239
Returns true if the given value is valid for that type.
120240
Types currently can be ``Char``, ``ASCIIString``, ``UTF8String``, ``UTF16String``, or ``UTF32String``
121241
Values for ``Char`` can be of type ``Char`` or ``UInt32``
122242
Values for ``ASCIIString`` and ``UTF8String`` can be of that type, or ``Vector{UInt8}``
123243
Values for ``UTF16String`` can be ``UTF16String`` or ``Vector{UInt16}``
124244
Values for ``UTF32String`` can be ``UTF32String``, ``Vector{Char}`` or ``Vector{UInt32}``
125245

246+
``isvalid(str, i)``
247+
248+
Tells whether index ``i`` is valid for the given string
249+
126250
.. function:: is_assigned_char(c) -> Bool
127251

128252
Returns true if the given char or integer is an assigned Unicode code point.
@@ -249,6 +373,22 @@
249373

250374
.. function:: isvalid(str, i)
251375

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+
252392
Tells whether index ``i`` is valid for the given string
253393

254394
.. function:: nextind(str, i)
@@ -377,31 +517,51 @@
377517
making a copy of the data and treating the NUL as a terminator
378518
rather than as part of the string.
379519

380-
.. function:: utf16(::Union{Ptr{UInt16},Ptr{Int16}} [, length])
520+
``utf16(::Union{Ptr{UInt16},Ptr{Int16}} [, length])``
381521

382522
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.
383523

384-
.. function:: utf32(s)
524+
.. function:: utf16(::Union{Ptr{UInt16},Ptr{Int16}} [, length])
385525

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.)
390532

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
393535
string (so that it is mostly invisible in Julia); this allows the
394536
string to be passed directly to external functions requiring
395537
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
399541
making a copy of the data and treating the NUL as a terminator
400542
rather than as part of the string.
401543

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+
402557
.. function:: utf32(::Union{Ptr{Char},Ptr{UInt32},Ptr{Int32}} [, length])
403558

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.
405565

406566
.. function:: wstring(s)
407567

@@ -410,4 +570,3 @@
410570
The synonym ``WString`` for ``UTF32String`` or ``UTF16String``
411571
is also provided.
412572

413-

‎doc/stdlib/test.rst

-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ binary install, you can run the test suite using ``Base.runtests()``.
1717
Run the Julia unit tests listed in ``tests``, which can be either a
1818
string or an array of strings, using ``numcores`` processors. (not exported)
1919

20-
2120
.. module:: Base.Test
22-
2321
Test Framework
2422
--------------
2523

0 commit comments

Comments
 (0)
Please sign in to comment.