[Top][All Lists]

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

[Octave-bug-tracker] [bug #52681] Bad reading for UTF-8 characters with

From: Markus Mützel
Subject: [Octave-bug-tracker] [bug #52681] Bad reading for UTF-8 characters with fscanf()
Date: Sat, 16 Dec 2017 19:52:38 -0500 (EST)
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0

Follow-up Comment #1, bug #52681 (project octave):

I made the following change to ov-re-mat.cc:

diff -r 37f0d04645a3 libinterp/octave-value/ov-re-mat.cc
--- a/libinterp/octave-value/ov-re-mat.cc       Sat Dec 16 21:38:33 2017 +0100
+++ b/libinterp/octave-value/ov-re-mat.cc       Sat Dec 16 23:07:10 2017 +0100
@@ -444,7 +444,7 @@
       int ival = octave::math::nint (d);
-      if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ())
+      if (ival < std::numeric_limits<signed char>::min () || ival >
std::numeric_limits<unsigned char>::max ())
           // FIXME: is there something better we could do?

This is certainly not how this should be fixed. However, with that change, all
characters from the example file can be successfully read without warning with
the following code:

fid = fopen("p1.txt");
a = fscanf(fid, "%s");

Judging from the above code junk, it looks like octave_values of type char are
always expected to be unsigned chars. However, char is signed by default in
I am not sure what the correct fix would be.


Reply to this item at:


  Message sent via/by Savannah

reply via email to

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