Replace invalid characters from HTML file with valid ones and save the file.

1 次查看(过去 30 天)
Hi all,
I am currently working on a script for editing the html file. (MATLAB 2013b)
The HTML file has some invalid characters like m³. And I want replace these characters e.g. m³ to m3.
I am able to read the html file as a cell of 4405x1 cell. Here, I am not able to use strrep command. Following is the code:
fid = fopen('C0TH_Doc_main.html','r');
MyText = textscan(fid,'%s','delimiter','\n');
strrep(MyText, 'm³', 'm3');
% rewrite the file
fid = fopen('C0TH_Doc_main.html','wt');
fprintf(fid,'%s\n',MyText);
fclose(fid);
Following is error screenshot
2020-01-30 11_06_38-MATLAB R2013b.jpg
Once all the characters are replaced, I want to preferably save it to the same HTML file or atleast wirte it into a new txt file.
Please provide any hints or other ways to complete this task.
Thank you in Advance

采纳的回答

Walter Roberson
Walter Roberson 2020-1-30
MyText = strrep(MyText{1}, 'm³', 'm3');
  2 个评论
Onkar Vader
Onkar Vader 2020-1-30
Thank you Mr. Roberson. It worked.
Further to write into an HTML file I used following code. Perhaps in future this will helpe someone. Following is the complete code:
2020-01-30 14_02_55-Editor - C__OnkarVader_C0_ASW_Work_C0_C0TH_TlAutoDocSkripts_CleanInvalidChar.m.jpg

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

产品


版本

R2013b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by