Ticket #160 (closed defect: fixed)
[PATCH] Save fails under wxMac
| Reported by: | ChrisDolan | Owned by: | |
|---|---|---|---|
| Priority: | critical | Milestone: | |
| Component: | editor | Version: | 0.19 |
| Keywords: | Cc: |
Description
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/Document.pm line 377.
Cannot find encoding "" at /Users/chris/Work/Padre/blib/lib/Padre/Document.pm 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?()'
47
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?())'
unknown-47
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
Change History
Changed 5 years ago by ChrisDolan
- Attachment mac-encoding.patch added
comment:1 Changed 5 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.

proposed Mac solution