Skip to content

Commit

Permalink
Fix JuliaLang#11379 deprecate utf32(Integer...)
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottPJones committed May 23, 2015
1 parent 7ddc684 commit bb93264
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@ Deprecated or removed
The two argument form `isvalid(type, value)` can be used with the above types, with values
of type `Vector{UInt8}`, `Vector{UInt16}`, `Vector{UInt32}`, and `Vector{Char}` ([#11241]).

* Instead of `utf32(64,123,...)` use `utf32(UInt32[64,123,...])` ([#11379]).

Julia v0.3.0 Release Notes
==========================

Expand Down Expand Up @@ -1420,3 +1422,4 @@ Too numerous to mention.
[#11145]: https://github.com/JuliaLang/julia/issues/11145
[#11171]: https://github.com/JuliaLang/julia/issues/11171
[#11241]: https://github.com/JuliaLang/julia/issues/11241
[#11379]: https://github.com/JuliaLang/julia/issues/11379
4 changes: 4 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -457,3 +457,7 @@ export float32_isvalid, float64_isvalid
@deprecate is_valid_utf8(str) isvalid(UTF8String, str)
@deprecate is_valid_utf16(str) isvalid(UTF16String, str)
@deprecate is_valid_utf32(str) isvalid(UTF32String, str)

# 11379

@deprecate utf32(c::Integer...) UTF32String(UInt32[c...,0])
9 changes: 0 additions & 9 deletions base/utf32.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,6 @@ next(s::UTF32String, i::Int) = (s.data[i], i+1)
endof(s::UTF32String) = length(s.data) - 1
length(s::UTF32String) = length(s.data) - 1

function utf32(c::Integer...)
a = Array(Char, length(c) + 1)
for i = 1:length(c)
a[i] = Char(c[i])
end
a[end] = Char(0)
UTF32String(a)
end

utf32(x) = convert(UTF32String, x)
convert(::Type{UTF32String}, c::Char) = UTF32String(Char[c, Char(0)])
convert(::Type{UTF32String}, s::UTF32String) = s
Expand Down
4 changes: 2 additions & 2 deletions test/unicode.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ else
end

str1 = "∀ ε > 0, ∃ δ > 0: |x-y| < δ ⇒ |f(x)-f(y)| < ε"
str2 = utf32(
str2 = UTF32String(UInt32[
8704, 32, 949, 32, 62, 32, 48, 44, 32, 8707, 32,
948, 32, 62, 32, 48, 58, 32, 124, 120, 45, 121, 124,
32, 60, 32, 948, 32, 8658, 32, 124, 102, 40, 120,
41, 45, 102, 40, 121, 41, 124, 32, 60, 32, 949
)
,0])
@test str1 == str2

# Cleanup unicode data
Expand Down

0 comments on commit bb93264

Please sign in to comment.