Skip to content

findfirst error message on UTF8Strings confusing #16610

Closed
@jiahao

Description

@jiahao
julia> findfirst("你好", "不好")
ERROR: UnicodeError: invalid character index
 in next(::String, ::Int64) at ./unicode/utf8.jl:65
 in getindex at ./strings/basic.jl:58 [inlined]
 in findnext(::String, ::String, ::Int64) at ./array.jl:745
 in findfirst(::String, ::String) at ./array.jl:751
 in eval(::Module, ::Any) at ./boot.jl:225
 in macro expansion at ./REPL.jl:92 [inlined]
 in (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:46

I realize this is not supposed to work, but a better error message is useful.

Reproducible on master and release-0.4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    error handlingHandling of exceptions by Julia or the userunicodeRelated to unicode characters and encodings

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions