Opened 11 years ago

Closed 11 years ago

#160 closed defect (fixed)

[PATCH] Save fails under wxMac

Reported by: ChrisDolan Owned by:
Priority: critical Milestone:
Component: editor Version: 0.19
Keywords: Cc:


Save fails with "Could not save: Invalid argument" and writes a zero-length file. Save as... fails too. Save on close fails too, and closes the document anyway, losing all changes.

I get this warning at the same time:

Use of uninitialized value in concatenation (.) or string at /Users/chris/Work/Padre/blib/lib/Padre/ line 377.
Cannot find encoding "" at /Users/chris/Work/Padre/blib/lib/Padre/ line 377.

Here's a diagnostic test:
% wxPerl -le'use Wx; print "\"" . Wx::Locale::GetSystemEncodingName?() . "\""'

Padre svn r1449, Mac 10.4, perl 5.8.6, Wx 0.88, wxwindows 2.8.8

I looked in the wxWidgets 2.8.8 source code and found the following in GetSystemEncodingName?() in src/common/intl.cpp

#elif defined(WXMAC)

default is just empty string, this resolves to the default system
encoding later


so it appears that the empty string is the norm for the encoding name. On the other hand, GetSystemEncoding?() yields

% wxPerl -le'use Wx; print Wx::Locale::GetSystemEncoding?()'

because it's making Mac-specific library calls. Trying to map that code to a name does not help.

% wxPerl -le'use Wx; print Wx::FontMapper::GetEncodingName?(Wx::Locale::GetSystemEncoding?())'

In my environment, I have LC_ALL=C and I do not have LANG set.

One solution would be an editor global fallback encoding, probably defaulting to the system encoding, if any, or utf-8 otherwise.

Attachments (1)

mac-encoding.patch (950 bytes) - added by ChrisDolan 11 years ago.
proposed Mac solution

Download all attachments as: .zip

Change History (4)

Changed 11 years ago by ChrisDolan

proposed Mac solution

comment:1 Changed 11 years ago by ChrisDolan

  • Summary changed from Save fails to [PATCH] Save fails under wxMac

I attached a proposed patch which works around the problem for me by assuming that an encoding name that is an empty string should be UTF-8. Someone who understands encodings on Mac better than I will need to either revise this solution, or work with the wxWidgets upstream for wxMac to improve that support.

comment:2 Changed 11 years ago by keedi

You're right. maybe I did not consider MAC environment.
I have to test more case like LC_ALL=C and unsetted LANG case, and MAC...

BTW what is the default encoding system on MAC?
and could you change the encoding what you want in MAC?

comment:3 Changed 11 years ago by ChrisDolan

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

Applied my patch. It's probably not the right long-term solution but it resolves the critical save problem.

Note: See TracTickets for help on using tickets.