How to convert array with hex to string?

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

2 Likes

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.

2 Likes

Thanks a lot!