[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: |
Dan Sebald |
Subject: |
[Octave-bug-tracker] [bug #52681] Bad reading for UTF-8 characters with fscanf() |
Date: |
Sun, 17 Dec 2017 15:44:53 -0500 (EST) |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0 |
Follow-up Comment #5, bug #52681 (project octave):
The issue is mainly, I think, that reading data from a file always casts the
read quantity to the specified format. Once past that, the goal seems more
achievable. Here's the shortest amount of code
fid = fopen('p1.txt', 'r');
d = fread(fid, 'uint8');
fclose(fid);
cstr = char(d');
[header] = textscan(cstr, '%s', 3){1};
[pais capital poblacion] = deal(textscan (c, '%s%s%d', 'headerlines', 1){:});
and some longer amount of code:
fid = fopen('p1.txt', 'r');
d = fread(fid, 'uint8');
fclose(fid);
c = char(d');
[pais capital poblacion] = strread(c, '%s %s %s');
header = {pais{1} capital{1} poblacion{1}};
pais = pais(2:end);
capital = capital(2:end);
poblacion = cellfun('str2num', poblacion(2:end));
Note that the translation
c = native2unicode(d');
doesn't seem necessary. I suppose the usefulness of the native2unicode()
comes in when it is something other than the Octave-assumed UTF-8.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?52681>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #52681] Bad reading for UTF-8 characters with fscanf(), anonymous, 2017/12/16
- [Octave-bug-tracker] [bug #52681] Bad reading for UTF-8 characters with fscanf(), Markus Mützel, 2017/12/16
- [Octave-bug-tracker] [bug #52681] Bad reading for UTF-8 characters with fscanf(), Dan Sebald, 2017/12/17
- [Octave-bug-tracker] [bug #52681] Bad reading for UTF-8 characters with fscanf(), Dan Sebald, 2017/12/17
- [Octave-bug-tracker] [bug #52681] Bad reading for UTF-8 characters with fscanf(), Andreas Weber, 2017/12/17
- [Octave-bug-tracker] [bug #52681] Bad reading for UTF-8 characters with fscanf(),
Dan Sebald <=
- [Octave-bug-tracker] [bug #52681] Bad reading for UTF-8 characters with fscanf(), Markus Mützel, 2017/12/17
- [Octave-bug-tracker] [bug #52681] Bad reading for UTF-8 characters with fscanf(), Dan Sebald, 2017/12/17
- [Octave-bug-tracker] [bug #52681] Bad reading for UTF-8 characters with fscanf(), Dan Sebald, 2017/12/17
- [Octave-bug-tracker] [bug #52681] Bad reading for UTF-8 characters with fscanf(), Dan Sebald, 2017/12/17
- [Octave-bug-tracker] [bug #52681] Bad reading for UTF-8 characters with fscanf(), Markus Mützel, 2017/12/21
- [Octave-bug-tracker] [bug #52681] Bad reading for UTF-8 characters with fscanf(), Dan Sebald, 2017/12/21
- [Octave-bug-tracker] [bug #52681] Bad reading for UTF-8 characters with fscanf(), Markus Mützel, 2017/12/22
- [Octave-bug-tracker] [bug #52681] Bad reading for UTF-8 characters with fscanf(), Markus Mützel, 2017/12/23
- [Octave-bug-tracker] [bug #52681] Bad reading for UTF-8 characters with fscanf(), Rik, 2017/12/26
- [Octave-bug-tracker] [bug #52681] Bad reading for UTF-8 characters with fscanf(), Dan Sebald, 2017/12/26