<div dir="ltr"><div>Hello Antoine!<br><br></div>Looks like the problem is solved, and actually has nothing to do with SciLab, but with file encoding!<br><br>Thank you very much!<br><br>Best regards,<br></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Wed, Nov 27, 2013 at 6:07 AM, Antoine Monmayrant <span dir="ltr"><<a href="mailto:antoine.monmayrant@laas.fr" target="_blank">antoine.monmayrant@laas.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"><div><div class="h5">
<div>On 11/26/2013 07:13 PM, Eduardo
Torrecillas wrote:<br>
</div>
</div></div><blockquote type="cite"><div><div class="h5">
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>Hello all,<br>
<br>
</div>
I currently have some text files and I would like
to extract information from them using Scilab.<br>
I have done this before, using mopen and mgetl,
for example.<br>
<br>
</div>
Don't know why, but strangely in this case it is not
working. I am using Scilab 5.4.1 on Ubuntu (but
Scilab 5.4.0 under Windows produced the same
result).<br>
<br>
</div>
Please check the attached text file.<br>
<br>
</div>
Simple code such as:<br>
<br>
fd=mopen('scilab_example.txt','r')<br>
</div>
phrase=mgetl(fd,1)<br>
<br>
</div>
Produces:<br>
<br>
</div>
phrase=ÿp<br>
<br>
</div>
If i still try to use mgetl, next lines are always returned as
empty.<br>
<br>
Does anybody have any clue on whats happening?<br>
<br>
Best regards,<br clear="all">
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div><br>
-- <br>
Eduardo Torrecillas<br>
AER-09
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<fieldset></fieldset>
<br>
</div></div><div class="im"><pre>_______________________________________________
users mailing list
<a href="mailto:users@lists.scilab.org" target="_blank">users@lists.scilab.org</a>
<a href="http://lists.scilab.org/mailman/listinfo/users" target="_blank">http://lists.scilab.org/mailman/listinfo/users</a>
</pre>
</div></blockquote>
<br>
Hi,<br>
<br>
Here is what I found:<br>
<br>
On my linux box, it seems your file is UTF-16:<br>
<br>
$ file scilab_example.txt <br>
scilab_example.txt: Little-endian UTF-16 Unicode text, with CRLF, CR
line terminators<br>
<br>
I cannot read it with mgetl, but I can use mgetstr:<br>
<br>
-->fd=mopen('scilab_example.txt','r')<br>
fd =<br>
<br>
1. <br>
<br>
-->chars=mgetstr(50)<br>
chars =<br>
<br>
�� 6 0 A 4 8 8 F / 1 <br>
<br>
-->chars=mgetstr(50)<br>
chars =<br>
<br>
9 - 1 9 - 2 1 4 8 8 * / 1 9 - 1 9 - 2 1 4 8 <br>
<br>
-->chars=mgetstr(50)<br>
chars =<br>
<br>
8 * / 1 9 - 1 9 - 2 1 4 8 8 * / 1 9 - 1 9 - 2 <br>
<br>
<br>
As you can see, it looks like a problem of encoding (the �� or the
ÿp are usually showing up when encoding is wrong). <br>
You can solve it that way:<br>
<br>
$ iconv -f UTF-16 -t LATIN1 scilab_example.txt > latin1.txt<br>
<br>
than in Scilab:<br>
<br>
-->fd=mopen('latin1.txt','r')<br>
fd =<br>
<br>
1. <br>
<br>
-->phrase=mgetl(fd,1)<br>
phrase =<br>
<br>
60A 488F/19-19-21 488*/19-19-21 488*/19-19-21
488*/19-19-21 <br>
<br>
Hope it helps<br>
<br>
<br>
<br>
</div>
<br>_______________________________________________<br>
users mailing list<br>
<a href="mailto:users@lists.scilab.org">users@lists.scilab.org</a><br>
<a href="http://lists.scilab.org/mailman/listinfo/users" target="_blank">http://lists.scilab.org/mailman/listinfo/users</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Eduardo Torrecillas<br>AER-09
</div>