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

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

[Octave-bug-tracker] [bug #55452] fopen() does not support encoding argu


From: Andrew Janke
Subject: [Octave-bug-tracker] [bug #55452] fopen() does not support encoding argument
Date: Sat, 9 Mar 2019 10:31:00 -0500 (EST)
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36

Follow-up Comment #9, bug #55452 (project octave):

Oddly, if I change the `fgetl ()` in my test to `textscan ()`, then it errors
out with `error: fopen: conversion from codepage 'utf-16' not supported` on
one of the passes, and the previous pass decodes a 0-long string. That's
strange, because I wouldn't expect using textscan() to affect the success of
subsequent fopen() calls.

Changed test code:


function out = slurp_file_one_line (file, encoding)
  [fh, msg] = fopen (file, "r", "native", encoding);
  if fh < 0
    error ("Failed opening file for reading: %s: %s", msg, file);
  endif
  %out = fgetl (fh);
  lines = textscan (fh, "%s", "Delimiter","");
  out = lines{1}{1};
  fclose (fh);
  out = out(:)';
endfunction


Result:


>> run_bug_55452_tests
Running fixed-text encoded file test ex-001:
Reference text: Hello, world! (13 chars)
running: ex-001 ISO-8859-1
  decoded: Hello, world! (13 chars)
  ok: ex-001 ISO-8859-1
running: ex-001 ISO-8859-15
  decoded: Hello, world! (13 chars)
  ok: ex-001 ISO-8859-15
running: ex-001 KOI8-R
  decoded: Hello, world! (13 chars)
  ok: ex-001 KOI8-R
running: ex-001 SHIFT_JIS
  decoded: Hello, world! (13 chars)
  ok: ex-001 SHIFT_JIS
running: ex-001 UTF-16
  decoded:  (0 chars)
  FAIL: ex-001 UTF-16
running: ex-001 UTF-16 no-bom
error: fopen: conversion from codepage 'utf-16' not supported
error: called from
    run_bug_55452_tests>slurp_file_one_line at line 51 column 13
    run_bug_55452_tests>run_fixed_text_encoded_file_test at line 31 column 18
    run_bug_55452_tests at line 11 column 5


    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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