Reputation: 1019
I have a file that contains a 16 character long sequence of UTF-8 which I want to read out and then convert to a 128 bitstring. The file is read out in the following way:
fid = fopen('file_0','r','n','UTF-8')
utf8_val = fgetl(fid);
Anyone now an an idea how I can convert the utf8_val into a 128 bitstring representation? Hope Matlab provides some function for that :).
Many thanks!
Upvotes: 0
Views: 811
Reputation: 124563
Why not read from the file directly as bytes
%# read bytes
fid = fopen('file.txt', 'rb');
b = fread(fid, '*uint8')';
fclose(fid);
Then if you wish you could convert it to a UTF-8 string
%# convert to Unicode string
s = native2unicode(b, 'UTF-8');
Upvotes: 1