# How do make a string from pointer to a piece memory that is in the format of a string?

**URL:** https://discourse.julialang.org/t/how-do-make-a-string-from-pointer-to-a-piece-memory-that-is-in-the-format-of-a-string/28534
**Category:** General Usage
**Tags:** performance, data
**Created:** [September 8, 2019, 10:10am UTC](https://discourse.julialang.org/t/how-do-make-a-string-from-pointer-to-a-piece-memory-that-is-in-the-format-of-a-string/28534 "2019-09-08T10:10:35Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)
#### Post date: [September 8, 2019, 10:10am UTC](https://discourse.julialang.org/t/how-do-make-a-string-from-pointer-to-a-piece-memory-that-is-in-the-format-of-a-string/28534/1 "2019-09-08T10:10:35Z")

</div>

I am writing a fast serializer of strings onto disk. What I found was that a String’s memory structure is very simple. It’s basically a `UInt64` followed by bytes. The first `UInt64` indicates the length of the string, and the subsequent bytes are the content of a string.

E.g…

```julia
a = reinterpret(UInt8, [2])
a = vcat(a, UInt8[63, 64])

b = String(UInt8[63, 64])

b_structure = unsafe_load.(pointer(b)-8, 1:10)

b_structure == a
a = reinterpret(UInt8, [2])
a = vcat(a, UInt8[63, 64])

b = String(UInt8[63, 64])

b_structure = unsafe_load.(pointer(b)-8, 1:10)

b_structure == a

```

Notice in the above `b` is a string. But `a` is just some array of `UInt`. If I convert the string `b` to its binary representation, you will see that they have the same structure.

Now if I want to make the content start from `pointer(a)` into a String. How do I do that? I need a **no-copy** solution! So `unsafe_string` doesn’t fit the bill here.

Thanks!!
