Skip to content

Commit ac25c58

Browse files
authored
Merge pull request #18152 from dbeach24/djcb/bugfix-16997-2
Adds support for String(x::Symbol) = string(x)
2 parents cbae586 + 431961d commit ac25c58

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

base/strings/basic.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ convert(::Type{Array{UInt8}}, s::AbstractString) = String(s).data
6262
convert(::Type{String}, s::AbstractString) = String(s)
6363
convert(::Type{Vector{Char}}, s::AbstractString) = collect(s)
6464
convert(::Type{Symbol}, s::AbstractString) = Symbol(s)
65+
convert(::Type{String}, s::Symbol) = unsafe_string(Cstring(s))
6566

6667
## generic supplied functions ##
6768

test/strings/basic.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ let
5555
# make symbol with invalid char
5656
sym = Symbol(Char(0xdcdb))
5757
@test string(sym) == string(Char(0xdcdb))
58+
@test String(sym) == string(Char(0xdcdb))
5859
@test expand(sym) === sym
5960
res = string(parse(string(Char(0xdcdb)," = 1"),1,raise=false)[1])
6061
@test res == """\$(Expr(:error, "invalid character \\\"\\udcdb\\\"\"))"""

0 commit comments

Comments
 (0)