#15583 closed defect (fixed)

wxTextFile doesn't read Old Mac line-endings (<CR>) correctly

Reported by: alexandrub Owned by:
Priority: normal Milestone:
Component: base Version: stable-latest
Keywords: wxTextFile, Mac Cc:
Blocked By: Blocking:
Patch: yes

Description

Modify any of the samples to read a text file with old mac line ending style = lines delimited by carriage return (CR = 13) - I attached one here.

#include "wx/textfile.h"
...
wxTextFile file(L"sample_file_with_CR_eol.txt");
file.Open();
wxString line = file.GetFirstLine();

If you break into the code you will notice the returned string is empty and the file is seek'ed to the next line.

The solution is a patch containing a few lines present in 2.8.12 code (attached).

Attachments (2)

sample_file_with_CR_eol.txt download (36 bytes) - added by alexandrub 11 months ago.
textfile_mac_ending_fix.patch download (581 bytes) - added by alexandrub 11 months ago.

Download all attachments as: .zip

Change History (3)

Changed 11 months ago by alexandrub

Changed 11 months ago by alexandrub

comment:1 Changed 11 months ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [75009]) Fix reading of files with Mac EOLs in wxTextFile.

The last CR-terminated line wasn't handled correctly.

Fix this now and add unit tests to ensure that it stays fixed.

Closes #15583.

Note: See TracTickets for help on using tickets.