What is the square symbol in text?
74 views (last 30 days)
Show older comments
Hi,
I am trying to read in a text file (of non-uniform format) and trying to extract a specific set of words.
When I have matlab print out the variables in the command window, I see the words are delimited by some character but I dont know what that is.
The delimiter looks like a square box and I tried searching and could not find what it is.
Does anyone know this is? and/or how to use it as a delimiting character? The word I am interested in is 'Arpeggiated'
I have attached my .txt file and the code is below. The text should show up in the command window.
Edit - I thought by saving the string to a new .txt file, I would be able to see the delimiter. This did not work either. There is no longer any space or delimiter between my words.
% input file
infile = '/Volumes/data/downloads/ARP Bells.txt';
% open file using fscanf
fid = fopen(infile,'r');
txt = fscanf(fid,'%s');
fclose(fid);
% first filter based on a specific string
ind = strfind(txt,'Aiyn'); % get index location
txt = txt(ind:end);
% second filter based on specific delimiter
tok = strtok(txt,'%');
% what is the square delimiter symbol?
tok = tok(230:end)
% save to see the symbol but doest show up in output
outfile = strrep(infile,'.smpr','_fixed.txt');
dlmwrite(outfile,tok,'delimiter','');
0 Comments
Accepted Answer
Geoff Hayes
on 19 Dec 2014
Norris - try converting the text string (from the original file with the squares) to an array of 8-bit unsigned integers so that you can see the ASCII code for that square (the code may be 254). Something like
uint8(txt)
Once you figure out the code for it, you can convert this integer value back to a string and use that as your delimiter.
More Answers (2)
David Sanchez
on 19 Dec 2014
I took a look at your "ARP Bells.txt" file. Why do you look for Aiyn string?
ind = strfind(txt,'Aiyn'); % get index location
txt = txt(ind:end);
there's any Aiyn in your txt, the lines above makes txt an empty string.
Besides, that square symbol is the representation of your system of an alien character (unusual symbol and letter in a language not supported by your system).
If you are interested in Arpeggiated, why don't you just look for it:
% first filter based on a specific string
ind = strfind(txt,'Arpeggiated'); % get index location
txt = txt(ind:end)
See Also
Categories
Find more on Characters and Strings in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!