Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

Fix SVG import crash with non-ASCII file paths on Windows

Abel Youfe22e1b43586
diff --git a/toonz/sources/image/svg/tiio_svg.cpp b/toonz/sources/image/svg/tiio_svg.cpp
index c712ef7d6..92346d57a 100644
--- a/toonz/sources/image/svg/tiio_svg.cpp
+++ b/toonz/sources/image/svg/tiio_svg.cpp
@@ -1793,7 +1793,15 @@ struct NSVGimage *nsvgParseFromFile(const char *filename) {
char *data = NULL;
struct NSVGimage *image = NULL;
+#if defined(_WIN32)
+ wchar_t wfilename[1024];
+ if (MultiByteToWideChar(CP_UTF8, 0, filename, -1, wfilename, 1024) > 0) {
+ fp = _wfopen(wfilename, L"rb");
+ }
+#else
fp = fopen(filename, "rb");
+#endif
+
if (!fp) goto error;
fseek(fp, 0, SEEK_END);
size = ftell(fp);
diff --git a/toonz/sources/toonzlib/toonzscene.cpp b/toonz/sources/toonzlib/toonzscene.cpp
index f702a192a..4f1d5bcf8 100644
--- a/toonz/sources/toonzlib/toonzscene.cpp
+++ b/toonz/sources/toonzlib/toonzscene.cpp
@@ -1057,7 +1057,7 @@ TFilePath ToonzScene::getImportedLevelPath(const TFilePath path) const {
//-----------------------------------------------------------------------------
-/* tzp,tzu->tlv */
+/* tzp,tzu->tlv, svg->pli */
bool ToonzScene::convertLevelIfNeeded(TFilePath &levelPath) {
LevelType ltype = getLevelType(levelPath);
TFilePath fp = levelPath;