Rank: 172990 based on 0 downloads (last 30 days) and 0 file submitted
photo

Mark Patterson

E-mail

Personal Profile:
Professional Interests:

 

Watch this Author's files

 

Comments and Ratings by Mark
Updated File Comments Rating
28 Sep 2010 unicode2ascii Converts unicode endcoded files to ASCII encoded files Author: Stefan Eireiner

Works well. The included isunicode function does not correctly release the file handle when it returns. The attached diff correct this.

--- isunicode.m 2010-09-20 18:25:56 +0000
+++ isunicode.m 2010-09-27 21:11:21 +0000
@@ -13,30 +13,22 @@
%
% (c) Version 1.0 by Stefan Eireiner (<a
href="mailto:stefan.eireiner@siemens.com?subject=isunicode">stefan.eirei
ner@siemens.com</a>)
% last change 10.04.2006
-%
-% Downloaded from:
-%
http://www.mathworks.com/matlabcentral/fileexchange/10686-unicode2ascii.
-%
-% See also: unicode2ascii.

isuc = false;
-if(nargin == 2)
- if(strcmpi(filename, 'string'))
- firstLine = varargin{1}(1:4);
+if nargin == 2 && strcmpi(filename, 'string')
+ firstLine = varargin{1}(1:4);
+else
+ fileInfo = dir(filename);
+ if(fileInfo.bytes < 4) % a unicode file incl. header can't be
smaller than 4 bytes if it shall display at least one char.
+ return;
end
-end
-
-if(~exist('firstLine', 'var'))
fin = fopen(filename,'r');
if (fin == -1) %does the file exist?
error(['File ' filename ' not found!'])
return;
end
- fileInfo = dir(filename);
- if(fileInfo.bytes < 4) % a unicode file incl. header can't be
smaller than 4 bytes if it shall display at least one char.
- return;
- end
firstLine = fread(fin,4)';
+ fclose(fin) ;
end

% assign all possible headers to variables
@@ -58,7 +50,3 @@
elseif(strfind(firstLine, utf32leheader) == 1)
isuc = 5;
end
-
-if(~exist('firstLine', 'var'))
- fclose(fin);
-end

Contact us