help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems with file encoding


From: Fritz Fischer
Subject: Re: Problems with file encoding
Date: Wed, 11 May 2011 14:12:19 +0200

Hello Richard,

you are right, I am trying to change decimal separator using the Octave-Script.
The CAD-file has commas as seperators and I want to change that so
I can calculate using Octave.

But how could this cause the problem with the strange rectangle character?

The input file I posted was a manual conversion from comma to dots, using "search and replace",
so it is not really converted using my Octave-script. The original file has commas as separators.

The error showing the rectangle character is a direct output from the octave-console,
if I am trying to run it. This is the relevant part of the script:

------
while( (~feof( fin )) )

s_old = fgetl(fin);
s_old   %show output

s_new = strrep(s_old, ',', '.');

fprintf(fout,'%s\n',s_new);
  
end
-----

Everything works fine if the input-file is saved to another encoding before...















2011/5/11 Balogh Richard, Ing. <address@hidden>
Try to change Your local settings for decimal separator - it used to be point, not comma.
Or, replace all dots in Your file with commas.

Richard Balogh


Dňa 11.5.2011 13:36, Fritz Fischer  wrote / napísal(a):
Hello!

I am using Octave for Windows (octave-forge)

I was trying to import a text file that was spit out by our CAD software into a nice octave matrix.

But this was not successful due to a problem with the encoding. I can not completly figure out
why this happens and hope that you can help me.

My text editor tells me that file from the CAD software is encoded in "UCS-2 Little Endian".
Just trying to read this file unmodified results in a row of strange characters in the output file
that I am trying to export.

The input file looks like this:

---
0.000    28.500
607.143    25.357
1214.286    22.903
1821.429    20.976
2428.571    19.448
---

Some code I am using:

---
fin = fopen(filename_input, 'rt');
...
s_old = fgetl(fin);
...
---

It seems that only the first line is read wrong, because if I display
all the lines read into the variable s_old it shows that typical ascii-rectangle followed by the
numbers it should show:

s_old =  ■0 , 0 0 0      2 8 , 5 0 0

All other rows look fine.

If I convert the input-file into ANSI or UTF8 before by using the text editor everything works fine.

Since this calculation has to be done to a lot of text files manually converting them to
a different encoding is not a solution.

Can I somehow change the input format that Octave accepts? Or can someone tell me
another solution to this?

Kind regards,
Walter



_______________________________________________
Help-octave mailing list
address@hidden
https://mailman.cae.wisc.edu/listinfo/help-octave



reply via email to

[Prev in Thread] Current Thread [Next in Thread]