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

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

[Octave-bug-tracker] [bug #63930] fprintf writes incorrect characters wh


From: Markus Mützel
Subject: [Octave-bug-tracker] [bug #63930] fprintf writes incorrect characters when converting the encoding
Date: Sat, 1 Apr 2023 11:02:12 -0400 (EDT)

Update of bug #63930 (project octave):

                  Status:             In Progress => Patch Submitted        

    _______________________________________________________

Follow-up Comment #41:

The attached patch checks if the buffer ends with a complete UTF-8 surrogate
when transcoding. 
With it, a modified version of `fprintf_bug5.m` outputs a file that looks
correct to me.
Here, the modified version (note the specified encoding in the `fopen`
command):

close all
clear
clc

fid = fopen('05.txt', 'w', 'n', 'Windows-1252');

fprintf(fid,
'ÀÂÈÊÌàäéèêìîöòùûÀÂÈÊÌàäéèêìîöòùû');
fprintf(fid,
'ÈÊÌàäîöòùûÀÂÈÊÌàäéèêìîöòéèêìùûÀÂ');
fprintf(fid,
'àäéèêìîöûÀÂÈÊÌàäéèòùûÀÂîöòùêìÈÊÌ');
fprintf(fid, 'ìîéèÌàäéê
îöòùûÀÂöòùûÀÂÈÊÌàäÈÊèê');
fprintf(fid,
'öòùûÀÂàäéÊèÈÊêìîöòùûÀÂÈÌàäéèÌêìî');
fprintf(fid,
'ÊÌàäùûÀÂÈéèÌàöòùûÀäéêìîÂÈÊèêìîöò');

fprintf(fid,
'ÌàäùûÀÂÈÊÌàÀÂéèêìêìîöòùîöòÈÊäéèû');
fprintf(fid,
'äéèÀÂÈÊÌàäéÈÊêìîöîöòùûÀòùûÌàèêìÂ');
fprintf(fid,
'êìîÊÌàäéèêìàäöòùûùûÀÂÈÊÀÂÈéèîöòÌ');
fprintf(fid,
'ùûÀèÌàäéêìîìîÂÈÊÌûÀÂÈÊèàäéöòöòùê');
fprintf(fid,
'ÀÂÈàäéêìîöòöòÊÌàäÂÈÊèêìéèÌùûùûÀî');
fprintf(fid,
'ÈÊÌéêìîöòùûùûàäéèÊèêìîöÌàäÀÂÀÂÈò');

f_error = fclose(fid);


I've only run some preliminary tests though. E.g., I haven't checked with
invalid UTF-8 sequences somewhere in or at the end of the output string.
Any feedback or help in testing is appreciated.


(file #54541)

    _______________________________________________________

Additional Item Attachment:

File name: bug63930-incomplete-utf-8.patch Size:2 KB
   
<https://file.savannah.gnu.org/file/bug63930-incomplete-utf-8.patch?file_id=54541>



    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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