# Why stringfy an array of UInt8s empties it?

**URL:** <https://discourse.julialang.org/t/why-stringfy-an-array-of-uint8s-empties-it/102389>\
**Category:** General Usage\
**Created:** [August 2, 2023, 10:15am UTC](https://discourse.julialang.org/t/why-stringfy-an-array-of-uint8s-empties-it/102389 "2023-08-02T10:15:12Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![rocco\_sprmnt21](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rocco_sprmnt21/32/20127_2.png) [@rocco\_sprmnt21](https://discourse.julialang.org/u/rocco_sprmnt21)\
**Post date:** [August 2, 2023, 11:08am UTC](https://discourse.julialang.org/t/why-stringfy-an-array-of-uint8s-empties-it/102389/4 "2023-08-02T11:08:37Z")

</div>

For me the problem arose in an attempt to write differently and compare the performance of the various proposed solutions to [this](https://discourse.julialang.org/t/multiway-string-substitution/102345/11) problem.  
It didn’t take me long to find where the problem was, but in much more complex code this “hidden” behavior can be much harder to spot.

```julia

function multisbs3(str,sstr, s)
    cstr,csstr,cs=codeunits.([str,sstr, s])
    lcstr,lcsstr,lcs = length.([cstr,csstr,cs])
    l=lcs-(lcstr-lcsstr)
    fp=findfirst(cstr, cs)
    tmp=Vector{UInt8}(undef,l)
    res=Vector{String}(undef,4)
    j=1
    while !isnothing(fp)
        fs,ls=first(fp),last(fp)
        copyto!(tmp,1, cs,1,fs-1)
        copyto!(tmp,fs,csstr)
        copyto!(tmp,ls,cs,ls+1,lcs-ls)
        res[j]=String(copy(tmp))
        j+=1
        fp=findnext(cstr, cs,first(fp)+1)
    end
    res
end

```

---

_[View the full topic](https://discourse.julialang.org/t/why-stringfy-an-array-of-uint8s-empties-it/102389)._
