What is the square symbol in text?
51 次查看(过去 30 天)
显示 更早的评论
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'
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/146532/image.png)
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 个评论
采纳的回答
Geoff Hayes
2014-12-19
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.
更多回答(2 个)
David Sanchez
2014-12-19
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)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!