JuliaStrings / InlineStrings.jl

Fixed-width string types for Julia
Other
45 stars 13 forks source link

ensure proper writing of codeunits #55

Closed ExpandingMan closed 1 year ago

ExpandingMan commented 2 years ago

There is a really nasty fallback for writing codeunits in Base:

write(io::IO, s::CodeUnits) = write(io, s.s)

what this means for InlineString is that it is writing the canonical binary representation of the InlineString, not the code units that are correctly returned by codeunits. This leads to confusing disasters like this.

This is a good demonstration of why it's really bad not to have a formal AbstractString interface. We really ought to open an issue in Base but it might take some background research to open an intelligent and actionable issue.

quinnj commented 1 year ago

Oof, that is indeed unfortunate. Sorry for the hassle and thanks for the fix here.

ExpandingMan commented 1 year ago

Yeah no worries, that would have been incredibly hard to catch for sure. Again, it's really more of a Base problem in my opinion.

ExpandingMan commented 1 year ago

This could use a tag when you get a chance.