octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #57304] Error message for non-UTF-8 encoded *.


From: Markus Mützel
Subject: [Octave-bug-tracker] [bug #57304] Error message for non-UTF-8 encoded *.m files
Date: Fri, 29 Nov 2019 08:10:09 -0500 (EST)
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0

Follow-up Comment #7, bug #57304 (project octave):

Sorry, my bad. "fread" doesn't convert the encoding. It just reads the bytes
as they are stored in the file. (At least this is what Matlab does.)

You could probably use fscanf or fgets/fgetl (still, I couldn't try):

fid = fopen ("angstrom.m", "r", "n", "iso-8859-1");
regexp (fscanf (fid, "%s")), "Hello")
fclose (fid);


Or combine "fread" with "native2unicode" (also works in Octave 5.1):

fid = fopen ("angstrom.m");
regexp (native2unicode (fread (fid).', "iso-8859-1"), "Hello")
fclose (fid);


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?57304>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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