Skip to content

Commit da86d36

Browse files
highlander: remove the utf8 function
1 parent 9f04510 commit da86d36

File tree

10 files changed

+10
-39
lines changed

10 files changed

+10
-39
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
@@ -1871,7 +1871,7 @@ Dict{String,Float64} with 2 entries:
18711871
"bar" => 42.0
18721872
"foo" => 0.0
18731873
1874-
julia> b = Dict(utf8("baz") => 17, utf8("bar") => 4711)
1874+
julia> b = Dict("baz" => 17, "bar" => 4711)
18751875
Dict{String,Int64} with 2 entries:
18761876
"bar" => 4711
18771877
"baz" => 17
@@ -2984,29 +2984,6 @@ Extract a named field from a `value` of composite type. The syntax `a.b` calls
29842984
"""
29852985
getfield
29862986

2987-
"""
2988-
utf8(::Array{UInt8,1})
2989-
2990-
Create a UTF-8 string from a byte array.
2991-
"""
2992-
utf8(::Vector{UInt8})
2993-
2994-
"""
2995-
utf8(::Ptr{UInt8}, [length])
2996-
2997-
Create a UTF-8 string from the address of a C (0-terminated) string encoded in UTF-8. A copy
2998-
is made; the ptr can be safely freed. If `length` is specified, the string does not have to
2999-
be 0-terminated.
3000-
"""
3001-
utf8(::Ptr{UInt8}, length::Int = 1)
3002-
3003-
"""
3004-
utf8(s)
3005-
3006-
Convert a string to a contiguous UTF-8 string (all characters must be valid UTF-8 characters).
3007-
"""
3008-
utf8(s)
3009-
30102987
"""
30112988
hvcat(rows::Tuple{Vararg{Int}}, values...)
30122989

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
@@ -891,7 +891,6 @@ export
891891
ucfirst,
892892
unescape_string,
893893
uppercase,
894-
utf8,
895894
warn,
896895
xdump,
897896

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
@@ -459,7 +459,7 @@ function snapshot(repo::GitRepo)
459459
work = try
460460
with(GitIndex, repo) do idx
461461
if length(readdir(path(repo))) > 1
462-
add!(idx, utf8("."))
462+
add!(idx, ".")
463463
write!(idx)
464464
end
465465
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
@@ -210,8 +210,8 @@ function matchall(re::Regex, str::String, overlap::Bool=false)
210210
matches
211211
end
212212

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

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

base/show.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,7 @@ Accept keyword args `c` for alternate single character marker.
11301130
"""
11311131
function replace_with_centered_mark(s::AbstractString;c::Char = '')
11321132
N = length(s)
1133-
return join(setindex!([utf8(" ") for i=1:N],string(c),ceil(Int,N/2)))
1133+
return join(setindex!([" " for i=1:N],string(c),ceil(Int,N/2)))
11341134
end
11351135

11361136
"""

base/unicode/utf8.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ write(io::IO, s::String) = write(io, s.data)
230230

231231
## transcoding to UTF-8 ##
232232

233-
utf8(x) = convert(String, x)
234233
convert(::Type{String}, s::String) = s
235234

236235
function convert(::Type{String}, dat::Vector{UInt8})
@@ -307,7 +306,7 @@ function convert(::Type{String}, a::Vector{UInt8}, invalids_as::AbstractString)
307306
end
308307
String(a)
309308
end
310-
convert(::Type{String}, s::AbstractString) = utf8(bytestring(s))
309+
convert(::Type{String}, s::AbstractString) = bytestring(s)
311310

312311
"""
313312
Converts an already validated vector of `UInt16` or `UInt32` to a `String`
@@ -351,6 +350,3 @@ function encode_to_utf8{T<:Union{UInt16, UInt32}}(::Type{T}, dat, len)
351350
end
352351
String(buf)
353352
end
354-
355-
utf8(p::Ptr{UInt8}) = String(bytestring(p))
356-
utf8(p::Ptr{UInt8}, len::Integer) = utf8(pointer_to_array(p, len))

0 commit comments

Comments
 (0)