Skip to content

Commit

Permalink
Don't deprecate ascii(::AbstractString)
Browse files Browse the repository at this point in the history
it's defined in base/strings/util.jl and used in the tests

Reinstate a few invalid encoding tests
  • Loading branch information
tkelman committed May 20, 2016
1 parent 1069013 commit cdd2859
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 0 additions & 1 deletion base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,6 @@ end
@deprecate ascii(p::Ptr{UInt8}, len::Integer) ascii(String(p, len))
@deprecate ascii(p::Ptr{UInt8}) ascii(String(p))
@deprecate ascii(v::Vector{UInt8}) ascii(String(v))
@deprecate ascii(s::AbstractString) ascii(String(p))
@deprecate ascii(x) ascii(convert(String, x))

@deprecate bytestring(s::Cstring) String(s)
Expand Down
2 changes: 1 addition & 1 deletion doc/stdlib/strings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

.. Docstring generated from Julia source
Create a string from the address of a C (0-terminated) string encoded as UTF-8. A copy is made so the ptr can be safely freed. If ``length`` is specified, the string does not have to be 0-terminated.
Create a string from the address of a C (0-terminated) string encoded as UTF-8. A copy is made so the pointer can be safely freed. If ``length`` is specified, the string does not have to be 0-terminated.

.. function:: String(s::AbstractString)

Expand Down
2 changes: 1 addition & 1 deletion test/strings/basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ foobaz(ch) = reinterpret(Char, typemax(UInt32))
@test ["b","c"].*"a" == ["ba","ca"]
@test ["a","b"].*["c","d"]' == ["ac" "ad"; "bc" "bd"]

# Make sure NULL pointer are handled consistently by String
# Make sure NULL pointers are handled consistently by String
@test_throws ArgumentError String(Ptr{UInt8}(0))
@test_throws ArgumentError String(Ptr{UInt8}(0), 10)

Expand Down
5 changes: 5 additions & 0 deletions test/unicode/checkstring.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ try
@test_throws UnicodeError Base.checkstring(UInt8[byt,0x80,0x80,0xc0])
end

# Long encoding of 0x01
@test_throws UnicodeError convert(String, b"\xf0\x80\x80\x80")
# Test ends of long encoded surrogates
@test_throws UnicodeError convert(String, b"\xf0\x8d\xa0\x80")
@test_throws UnicodeError convert(String, b"\xf0\x8d\xbf\xbf")
# Long encodings
@test_throws UnicodeError Base.checkstring(b"\xf0\x80\x80\x80")
@test Base.checkstring(b"\xc0\x81"; accept_long_char=true) == (1,0x1,0,0,0)
Expand Down

0 comments on commit cdd2859

Please sign in to comment.