User`s guide
R2012a
7-6
Technical Q&A QA1067 “Setting environment variables for user processes” at http://
developer.apple.com/library/mac/#qa/qa1067/_index.html.
2
Close MATLAB if it is currently running.
3
Start MATLAB by double-clicking the MATLAB icon in the Applications folder.
How to Convert Text File Encoding to UTF-8
Before converting a file, copy the file to a new directory.
Use the Mac OS X TextEdit application to convert the file encoding. For example:
1
Open a MATLAB text file with TextEdit.
2
Select File -> Save as...
3
Change the file name.
4
Change Plain Text Encoding: to Unicode (UTF-8).
5
Save the file.
Alternatively, the following MATLAB function, convert_file_encoding, creates a
new text file with different encoding.
function convert_file_encoding(infile,outfile,from_encoding,to_encoding)
if strcmp(infile(end-2:end),'mdl');
isMDL = 1;
else
isMDL = 0;
end
fpIn = fopen(infile,'r','n',from_encoding);
fpOut = fopen(outfile,'w','n',to_encoding);
while feof(fpIn) == 0
lineIn = fgets(fpIn);
if isMDL && strncmp('SavedCharacterEncoding',strtrim(lineIn),22)
lineIn = regexprep(lineIn,from_encoding,to_encoding);
end
fwrite(fpOut,lineIn,'char');
end
fclose(fpIn);