# String.data in Compat.jl?

**URL:** <https://discourse.julialang.org/t/string-data-in-compat-jl/1619>\
**Category:** Internals & Design\
**Created:** [January 20, 2017, 5:56pm UTC](https://discourse.julialang.org/t/string-data-in-compat-jl/1619 "2017-01-20T17:56:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lobingera](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lobingera/32/211_2.png) [@lobingera](https://discourse.julialang.org/u/lobingera)\
**Post date:** [January 20, 2017, 5:56pm UTC](https://discourse.julialang.org/t/string-data-in-compat-jl/1619/1 "2017-01-20T17:56:04Z")

</div>

```julia
julia> a = "str"
"str"

julia> b = a.data
ERROR: type String has no field data
Use `Vector{UInt8}(str)` instead.

```

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [January 20, 2017, 6:50pm UTC](https://discourse.julialang.org/t/string-data-in-compat-jl/1619/2 "2017-01-20T18:50:16Z")

</div>

What are you suggesting? The newer form should work on all versions supported by compat

---

<div class="post-metadata">

**Author:** ![lobingera](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lobingera/32/211_2.png) [@lobingera](https://discourse.julialang.org/u/lobingera)\
**Post date:** [January 20, 2017, 8:34pm UTC](https://discourse.julialang.org/t/string-data-in-compat-jl/1619/3 "2017-01-20T20:34:22Z")

</div>

I hit send before completely formulating the question. I didn’t See from the compat docu if it’s Supported.

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [January 20, 2017, 8:48pm UTC](https://discourse.julialang.org/t/string-data-in-compat-jl/1619/4 "2017-01-20T20:48:21Z")

</div>

What’s the question then? There’s nothing that needs to be supported in Compat.

---

<div class="post-metadata">

**Author:** ![lobingera](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lobingera/32/211_2.png) [@lobingera](https://discourse.julialang.org/u/lobingera)\
**Post date:** [January 21, 2017, 11:16am UTC](https://discourse.julialang.org/t/string-data-in-compat-jl/1619/5 "2017-01-21T11:16:32Z")

</div>

I was confused. Initially i tried to ask: How can i use Compat for string.data issues. But (as you wrote) str\_data = Vector{UInt8}(str) is working in julia versions, independent of Compat.

---

<div class="post-metadata">

**Author:** ![jameson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jameson/32/23_2.png) [@jameson](https://discourse.julialang.org/u/jameson)\
**Post date:** [January 25, 2017, 1:52am UTC](https://discourse.julialang.org/t/string-data-in-compat-jl/1619/6 "2017-01-25T01:52:45Z")

</div>

It might be nice if we could suggest `use b"str"` instead, but I don’t think we can know that the String came from a constant.
