diff options
| author | Eduard Braun <eduard.braun2@gmx.de> | 2018-09-24 21:56:17 +0000 |
|---|---|---|
| committer | Patrick Storz <eduard.braun2@gmx.de> | 2018-09-29 21:04:56 +0000 |
| commit | ef8f5e3e5e081b2495f7a39e0d14f62309799723 (patch) | |
| tree | 19cd6aa2bfa7ccada761ce0071a6884c7df8ac71 /src/io/inkscapestream.cpp | |
| parent | fix 90 deg cw/ccw rotation with inverted y-axis (diff) | |
| download | inkscape-ef8f5e3e5e081b2495f7a39e0d14f62309799723.tar.gz inkscape-ef8f5e3e5e081b2495f7a39e0d14f62309799723.zip | |
Inkscapestream: Fix write methods for string types
As we output UTF8 encoded strings to normal streams we can (and
should) put one byte at a time. Iterating over an ustring will give
us "unichar"s with up to four bytes, though, which is bound to fail
when written to a stream.
Using Glib::ustring::raw() gives us a std::string with the raw
(but still UTF8 encoded) character array that can be iterated
byte-wise and output to the stream as-is.
Diffstat (limited to 'src/io/inkscapestream.cpp')
| -rw-r--r-- | src/io/inkscapestream.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/io/inkscapestream.cpp b/src/io/inkscapestream.cpp index 3042ecff7..be69e4139 100644 --- a/src/io/inkscapestream.cpp +++ b/src/io/inkscapestream.cpp @@ -501,9 +501,8 @@ Writer &BasicWriter::writeChar(char ch) */ Writer &BasicWriter::writeUString(Glib::ustring &str) { - for (auto it = str.begin(); it != str.end(); it++) { - put(*it); - } + std::string tmp = str.raw(); + writeStdString(tmp); return *this; } @@ -512,8 +511,9 @@ Writer &BasicWriter::writeUString(Glib::ustring &str) */ Writer &BasicWriter::writeStdString(std::string &str) { - Glib::ustring tmp(str); - writeUString(tmp); + for (auto it = str.begin(); it != str.end(); it++) { + put(*it); + } return *this; } @@ -522,12 +522,12 @@ Writer &BasicWriter::writeStdString(std::string &str) */ Writer &BasicWriter::writeString(const char *str) { - Glib::ustring tmp; + std::string tmp; if (str) tmp = str; else tmp = "null"; - writeUString(tmp); + writeStdString(tmp); return *this; } |
