Skip to content

Commit be45b8b

Browse files
deprecate utf8 for String
1 parent 8b1b350 commit be45b8b

24 files changed

+38
-103
lines changed

base/REPL.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,11 +323,11 @@ An editor may have converted tabs to spaces at line """
323323

324324
function hist_getline(file)
325325
while !eof(file)
326-
line = utf8(readline(file))
326+
line = readline(file)
327327
isempty(line) && return line
328328
line[1] in "\r\n" || return line
329329
end
330-
return utf8("")
330+
return ""
331331
end
332332

333333
function hist_from_file(hp, file)

base/docs/helpdb/Base.jl

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1854,7 +1854,7 @@ Dict{String,Float64} with 2 entries:
18541854
"bar" => 42.0
18551855
"foo" => 0.0
18561856
1857-
julia> b = Dict(utf8("baz") => 17, utf8("bar") => 4711)
1857+
julia> b = Dict("baz" => 17, "bar" => 4711)
18581858
Dict{String,Int64} with 2 entries:
18591859
"bar" => 4711
18601860
"baz" => 17
@@ -2962,29 +2962,6 @@ Extract a named field from a `value` of composite type. The syntax `a.b` calls
29622962
"""
29632963
getfield
29642964

2965-
"""
2966-
utf8(::Array{UInt8,1})
2967-
2968-
Create a UTF-8 string from a byte array.
2969-
"""
2970-
utf8(::Vector{UInt8})
2971-
2972-
"""
2973-
utf8(::Ptr{UInt8}, [length])
2974-
2975-
Create a UTF-8 string from the address of a C (0-terminated) string encoded in UTF-8. A copy
2976-
is made; the ptr can be safely freed. If `length` is specified, the string does not have to
2977-
be 0-terminated.
2978-
"""
2979-
utf8(::Ptr{UInt8}, length::Int = 1)
2980-
2981-
"""
2982-
utf8(s)
2983-
2984-
Convert a string to a contiguous UTF-8 string (all characters must be valid UTF-8 characters).
2985-
"""
2986-
utf8(s)
2987-
29882965
"""
29892966
hvcat(rows::Tuple{Vararg{Int}}, values...)
29902967

base/env.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function access_env(onError::Function, str::AbstractString)
3434
var = cwstring(str)
3535
len = _getenvlen(var)
3636
if len == 0
37-
return Libc.GetLastError() != ERROR_ENVVAR_NOT_FOUND ? utf8("") : onError(str)
37+
return Libc.GetLastError() != ERROR_ENVVAR_NOT_FOUND ? "" : onError(str)
3838
end
3939
val = zeros(UInt16,len)
4040
ret = ccall(:GetEnvironmentVariableW,stdcall,UInt32,(Ptr{UInt16},Ptr{UInt16},UInt32),var,val,len)

base/exports.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,6 @@ export
887887
ucfirst,
888888
unescape_string,
889889
uppercase,
890-
utf8,
891890
utf16,
892891
utf32,
893892
warn,

base/libc.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ function FormatMessage end
259259
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK,
260260
C_NULL, e, 0, lpMsgBuf, 0, C_NULL)
261261
p = lpMsgBuf[1]
262-
len == 0 && return utf8("")
262+
len == 0 && return ""
263263
buf = Array(UInt16, len)
264264
unsafe_copy!(pointer(buf), p, len)
265265
ccall(:LocalFree,stdcall,Ptr{Void},(Ptr{Void},),p)

base/libgit2.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ function snapshot(repo::GitRepo)
465465
work = try
466466
with(GitIndex, repo) do idx
467467
if length(readdir(path(repo))) > 1
468-
add!(idx, utf8("."))
468+
add!(idx, ".")
469469
write!(idx)
470470
end
471471
write_tree!(idx)

base/precompile.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,6 @@ precompile(Base.UInt, (UInt,))
400400
precompile(Base.unsafe_copy!, (Array{Dict{Any, Any}, 1}, Int, Array{Dict{Any, Any}, 1}, Int, Int))
401401
precompile(Base.unsafe_copy!, (Ptr{Dict{Any, Any}}, Ptr{Dict{Any, Any}}, Int))
402402
precompile(Base.unshift!, (Array{Any,1}, Task))
403-
precompile(Base.utf8, (String,))
404403
precompile(Base.uv_error, (String, Bool))
405404
precompile(Base.uvfinalize, (Base.TTY,))
406405
precompile(Base.vcat, (Base.LineEdit.Prompt,))

base/regex.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ function matchall(re::Regex, str::String, overlap::Bool=false)
209209
matches
210210
end
211211

212-
matchall(re::Regex, str::Union{String,SubString}, overlap::Bool=false) =
213-
matchall(re, utf8(str), overlap)
212+
matchall(re::Regex, str::SubString, overlap::Bool=false) =
213+
matchall(re, String(str), overlap)
214214

215215
function search(str::Union{String,SubString}, re::Regex, idx::Integer)
216216
if idx > nextind(str,endof(str))

base/show.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,7 @@ Accept keyword args `c` for alternate single character marker.
11891189
"""
11901190
function replace_with_centered_mark(s::AbstractString;c::Char = '')
11911191
N = length(s)
1192-
return join(setindex!([utf8(" ") for i=1:N],string(c),ceil(Int,N/2)))
1192+
return join(setindex!([" " for i=1:N],string(c),ceil(Int,N/2)))
11931193
end
11941194

11951195
"""

base/strings/basic.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ String(s::Vector{UInt8}) =
3232
String(p::Ptr{UInt8}, [length::Integer])
3333
3434
Create a string from the address of a C (0-terminated) string encoded as UTF-8.
35-
A copy is made so the ptr can be safely freed. If `length` is specified, the string
36-
does not have to be 0-terminated.
35+
A copy is made so the pointer can be safely freed. If `length` is specified, the
36+
string does not have to be 0-terminated.
3737
"""
3838
function String(p::Union{Ptr{UInt8},Ptr{Int8}}, len::Integer)
3939
p == C_NULL && throw(ArgumentError("cannot convert NULL to string"))

0 commit comments

Comments
 (0)