# How to convert array with hex to string?

**URL:** https://discourse.julialang.org/t/how-to-convert-array-with-hex-to-string/5980
**Category:** General Usage
**Created:** [September 19, 2017, 4:50pm UTC](https://discourse.julialang.org/t/how-to-convert-array-with-hex-to-string/5980 "2017-09-19T16:50:27Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![hvillalo](https://avatars.discourse-cdn.com/v4/letter/h/7feea3/32.png) [@hvillalo](https://discourse.julialang.org/u/hvillalo)
#### Post date: [September 19, 2017, 4:50pm UTC](https://discourse.julialang.org/t/how-to-convert-array-with-hex-to-string/5980/1 "2017-09-19T16:50:27Z")

</div>

Hi,

I’m trying to convert part of an array to a string. In the example below, I want to obtain the string:  
“GPT 120 kHz” from the following array:

julia\> m[853:863]  
11-element Array{UInt8,1}:  
0x47  
0x50  
0x54  
0x20  
0x31  
0x32  
0x30  
0x20  
0x6b  
0x48  
0x7a

This works but is impractical:  
julia\> “\u47\u50\u54\u20\u31\u32\u30\u20\u6b\u48\u7a”  
“GPT 120 kHz”

And also this:  
julia\> Char(m[853])  
‘G’: ASCII/Unicode U+0047 (category Lu: Letter, uppercase)

I have tried using string.(m[853:863]) but with no success… Any idea will be greatly appreciated

Héctor

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [September 19, 2017, 5:16pm UTC](https://discourse.julialang.org/t/how-to-convert-array-with-hex-to-string/5980/2 "2017-09-19T17:16:39Z")

</div>

`String(m[853:863])` is what you want here: you want the `String` constructor that creates a string directly from raw bytes in ASCII / UTF-8 encoding.

---

<div class="post-metadata">

### Author: ![hvillalo](https://avatars.discourse-cdn.com/v4/letter/h/7feea3/32.png) [@hvillalo](https://discourse.julialang.org/u/hvillalo)
#### Post date: [September 19, 2017, 5:23pm UTC](https://discourse.julialang.org/t/how-to-convert-array-with-hex-to-string/5980/3 "2017-09-19T17:23:22Z")

</div>

> [@stevengj](#):
>
> String(m[853:863]) is what you want here: you want the String constructor that creates a string directly from raw bytes in ASCII / UTF-8 encoding.

Thanks a lot!
