One more request, if I may - Is it possible to print only the document of the web, not the entire page (I think it's done in document.write() method in javascript but have no idea how to integrate it with the above code).
excellent work, really helped me !
Is it possible to create the same function also with firefox? (the problem with the protected zone in IE is a bit bothering)
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
Comment only
31 Jan 2010
unicode2ascii
Converts unicode endcoded files to ASCII encoded files
Comment only