Skip to content

Fix bug of to_ascii constructor from vectors and pointers #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 19, 2020
Merged

Fix bug of to_ascii constructor from vectors and pointers #10

merged 1 commit into from
Dec 19, 2020

Conversation

jessymilare
Copy link
Contributor

Correct a few typos that prevents creation of ascii strings from vectors and pointers. E.g.:

julia> v = collect(codeunits("asdfghjkl\0"))
10-element Array{UInt8,1}:
 0x61
 0x73
 0x64
 0x66
 0x67
 0x68
 0x6a
 0x6b
 0x6c
 0x00

julia> to_ascii(v)
ERROR: UndefVarError: str not defined
Stacktrace:
 [1] isascii(::Array{UInt8,1}) at C:\Users\jessy\.julia\packages\StrBase\3wQxZ\src\utf8.jl:158
 [2] convert(::Type{ASCIIStr}, ::Array{UInt8,1}) at C:\Users\jessy\.julia\packages\StrBase\3wQxZ\src\ascii.jl:52
 [3] to_ascii(::Array{UInt8,1}) at C:\Users\jessy\.julia\packages\StrBase\3wQxZ\src\legacy.jl:6
 [4] top-level scope at REPL[109]:1

julia> ASCIIStr(v)
ERROR: UndefVarError: str not defined
Stacktrace:
 [1] isascii(::Array{UInt8,1}) at C:\Users\jessy\.julia\packages\StrBase\3wQxZ\src\utf8.jl:158
 [2] convert(::Type{ASCIIStr}, ::Array{UInt8,1}) at C:\Users\jessy\.julia\packages\StrBase\3wQxZ\src\ascii.jl:52
 [3] ASCIIStr(::Array{UInt8,1}) at C:\Users\jessy\.julia\packages\StrBase\3wQxZ\src\types.jl:55
 [4] top-level scope at REPL[110]:1

julia> to_ascii(pointer(v))
ERROR: UndefVarError: p not defined
Stacktrace:
 [1] to_ascii(::Ptr{UInt8}) at C:\Users\jessy\.julia\packages\StrBase\3wQxZ\src\legacy.jl:7
 [2] top-level scope at REPL[111]:1

@jessymilare
Copy link
Contributor Author

I believe the error is unrelated to the changes I've made.

Copy link
Member

@ScottPJones ScottPJones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! I should have tested the "legacy" constructors more!

@ScottPJones ScottPJones merged commit 077b721 into JuliaString:master Dec 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants