Parkinbot wrote
Both OpenSCAD editors do not save UTF8-encoded files on Windows. You can
use Notepad to check that.
Sorry, I was wrong in this. Notepad guesses utf8 from the file content.
--
View this message in context: http://forum.openscad.org/After-changement-it-doesn-t-work-any-longer-use-seems-to-work-the-wrong-way-or-work-not-any-more-tp20017p20064.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
String literals in OpenSCAD are unicode, not UTF8 so it should be:
import("\u00f6\u00e4\u00fc.stl");
That produces the correct error message but still doesn't work.
On 12 January 2017 at 21:18, Parkinbot rudolf@parkinbot.com wrote:
HxD shows "C3 A4 C3 B6 C3 BC" for "äöü" saved with OpenSCAD Editor in
Windows. So far this is, as expected, and it is UTF8.
Now: I can save my scadfile using "äöü.scad" as filename and open it again,
no problem. I can also export it as STL. This is done in native coding!!!,
the screenshot shows this. But I can't include/use this file or import it
into any other scad file. Have a look at the screenshot.
Further note that it is not possible to write something like
include <\uC3A4\uC3B6\uC3BC.scad>
but that wouldn't help either, because also the following doesn't work
import ("äöü.stl"); // WARNING: Can't open import file
'C:/Users/Rudi/Documents/3D Designs\äöü.stl'.
import ("���.stl"); // WARNING: Can't open import file
'C:/Users/Rudi/Documents/3D Designs\���.stl'.
import ("\uC3A4\uC3B6\uC3BC.stl"); // WARNING: Can't open import file
'C:/Users/Rudi/Documents/3D Designs\쎤쎶쎼.stl'.
with ��� copied from the console.
http://forum.openscad.org/file/n20062/Umlaute.png
--
View this message in context: http://forum.openscad.org/
After-changement-it-doesn-t-work-any-longer-use-seems-to-
work-the-wrong-way-or-work-not-any-more-tp20017p20062.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
without knowing the source code at all, I tracked down the these lines in
https://github.com/openscad/openscad/blob/master/src/import_stl.cc#L60
which open a file for stl import.
// Open file and position at the end
std::ifstream f(filename.c_str(), std::ios::in | std::ios::binary |
std::ios::ate);
if (!f.good()) {
PRINTB("WARNING: Can't open import file '%s'.", filename);
return p;
}
reading the following stackoverflow issue, points to the cause of the
problem (and its solution).
http://stackoverflow.com/questions/821873/how-to-open-an-stdfstream-ofstream-or-ifstream-with-a-unicode-filename
--
View this message in context: http://forum.openscad.org/After-changement-it-doesn-t-work-any-longer-use-seems-to-work-the-wrong-way-or-work-not-any-more-tp20017p20066.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
So import needs to use the 16 bit stream ctor. include and use need to
convert from UTF8 source code to Unicode first. I.e. they need to mimic the
string literal functionality in < > the same as in quotes.
On 12 January 2017 at 22:26, Parkinbot rudolf@parkinbot.com wrote:
without knowing the source code at all, I tracked down the these lines in
https://github.com/openscad/openscad/blob/master/src/import_stl.cc#L60
which open a file for stl import.
// Open file and position at the end
std::ifstream f(filename.c_str(), std::ios::in | std::ios::binary |
std::ios::ate);
if (!f.good()) {
PRINTB("WARNING: Can't open import file '%s'.", filename);
return p;
}
reading the following stackoverflow issue, points to the cause of the
problem (and its solution).
http://stackoverflow.com/questions/821873/how-to-open-
an-stdfstream-ofstream-or-ifstream-with-a-unicode-filename
--
View this message in context: http://forum.openscad.org/
After-changement-it-doesn-t-work-any-longer-use-seems-to-
work-the-wrong-way-or-work-not-any-more-tp20017p20066.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
So import needs to use the 16 bit stream ctor. include
and use need to convert from UTF8 source code to Unicode
first. I.e. they need to mimic the string literal
functionality in < > the same as in quotes.
Basically yes, unfortunately getting this to work across
all platforms makes it a bit more complicated (e.g. the
solution linked in the previous messages is not available
on other platforms).
I guess it's now at least clear, that the issue is related
to https://github.com/openscad/openscad/pull/1296
I'll add a link to this discussion to the github issue...
ciao,
Torsten.
You can use qt as a portability abstraction layer. Use QFile to open the
file. The filename is passed as a QString. Use QString::fromUtf8() to
construct the filename argument.
On Friday, 13 January 2017, Torsten Paul Torsten.Paul@gmx.de wrote:
So import needs to use the 16 bit stream ctor. include
and use need to convert from UTF8 source code to Unicode
first. I.e. they need to mimic the string literal
functionality in < > the same as in quotes.
Basically yes, unfortunately getting this to work across
all platforms makes it a bit more complicated (e.g. the
solution linked in the previous messages is not available
on other platforms).
I guess it's now at least clear, that the issue is related
to https://github.com/openscad/openscad/pull/1296
I'll add a link to this discussion to the github issue...
ciao,
Torsten.
OpenSCAD mailing list
Discuss@lists.openscad.org javascript:;
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
On 01/13/2017 03:00 PM, doug moen wrote:
You can use qt as a portability abstraction layer. Use QFile to open
the file. The filename is passed as a QString. Use QString::fromUtf8()
to construct the filename argument.
No, not at this point. The core is supposed to not depend on Qt.
I think that's valuable feature worth preserving.
ciao,
Torsten.
If the QT library is used to keep OpenSCAD platform independent, then I think
it should be fully leveraged. File open/reading/writing should be done
through this layer.
--
View this message in context: http://forum.openscad.org/After-changement-it-doesn-t-work-any-longer-use-seems-to-work-the-wrong-way-or-work-not-any-more-tp20017p20072.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
On 01/13/2017 06:49 PM, adrian wrote:
If the QT library is used to keep OpenSCAD platform independent,
then I think it should be fully leveraged. File open/reading/writing
should be done through this layer.
Considering the large number of requests for either a non-GUI
dependent version or a libopenscad, I have to disagree. Also
Qt is not some kind of magic thing that just solves all platform
issues. In this specific case it would help probably, but there
are also other solutions.
ciao,
Torsten.
I misunderstood the role of QT in OpenSCAD. I didn't realize that it is not
to be used in the core.
In that case, you could use boost::filesystem::ifstream to open the file
and boost::filesystem::path to represent the UTF-8 filename argument. The
advantage is that this API is part of C++17, so when OpenSCAD migrates to
C++17, you can switch to using std::filesystem. The disadvantage is that
the API is less straightforward than QT5. Here is a discussion about
constructing a filesystem::path from a UTF-8 string:
http://boost.2283326.n4.nabble.com/boost-filesystem-path-as-utf-8-td4320098.html
Another approach is that the core uses an abstract interface for opening
and reading files, and the client implements that interface. Kind of like
the outputhandler abstraction used by the core to write ECHO, WARNING and
ERROR messages to the console. Then the client could use QFile to open
included and used files, without polluting the core.
On 13 January 2017 at 12:56, Torsten Paul Torsten.Paul@gmx.de wrote:
On 01/13/2017 06:49 PM, adrian wrote:
If the QT library is used to keep OpenSCAD platform independent,
then I think it should be fully leveraged. File open/reading/writing
should be done through this layer.
Considering the large number of requests for either a non-GUI
dependent version or a libopenscad, I have to disagree. Also
Qt is not some kind of magic thing that just solves all platform
issues. In this specific case it would help probably, but there
are also other solutions.
ciao,
Torsten.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org