[Solved] [Bug] [Windows] Techdraw error message with special characters in the username

Discussions about the development of the TechDraw workbench
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
Haavard
Posts: 217
Joined: Wed Feb 17, 2021 10:48 pm

[Solved] [Bug] [Windows] Techdraw error message with special characters in the username

Post by Haavard »

I get the following message in the report view when inserting a view on a new techdraw page:

Code: Select all

09:10:21  Cannot open LineGroup file: C:/Users/SpecialUsernameÆÅØ/AppData/Local/Programs/FreeCAD 0.20/data/Mod/TechDraw/LineGroup/LineGroup.csv
09:10:21  LineGroup::invalid entry in C:/Users/SpecialUsernameÆÅØ/AppData/Local/Programs/FreeCAD 0.20/data/Mod/TechDraw/LineGroup/LineGroup.csv
I would guess it is related to other special character issues:
https://forum.freecadweb.org/viewtopic.php?f=3&t=69825
https://forum.freecadweb.org/viewtopic.php?f=19&t=71219

Code: Select all

OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.20.1.29410 (Git)
Build type: Release
Branch: releases/FreeCAD-0-20
Hash: f5d13554ecc7a456fb6e970568ae5c74ba727563
Python 3.8.10, Qt 5.15.2, Coin 4.0.1, Vtk 8.2.0, OCC 7.6.3
Locale: Norwegian Bokmal/Norway (nb_NO)
Last edited by Haavard on Sat Aug 20, 2022 10:24 pm, edited 2 times in total.
User avatar
wandererfan
Veteran
Posts: 6265
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: [Bug] [Windows] Techdraw error message with special characters in the username

Post by wandererfan »

Haavard wrote: Fri Aug 19, 2022 7:23 am I get the following message in the report view when inserting a view on a new techdraw page:
If you type "App.getResourceDir()" in the Python console, what do you get?
User avatar
bensay
Posts: 202
Joined: Wed Dec 22, 2021 8:14 pm
Location: Danmark
Contact:

Re: [Bug] [Windows] Techdraw error message with special characters in the username

Post by bensay »

I am pretty sure it is this bug: https://forum.freecadweb.org/viewtopic.php?f=35&t=70876

The folder has gotten a new name after FreeCAD was updated to 20.1.

1) Did you start getting these errors right after having update to 20.1
2) Check if the folder C:/Users/SpecialUsernameÆÅØ/AppData/Local/Programs/FreeCAD 0.20/ exists - it is probably replaced by C:/Users/SpecialUsernameÆÅØ/AppData/Local/Programs/FreeCAD 0.20.1/ now
Last edited by bensay on Fri Aug 19, 2022 9:43 pm, edited 1 time in total.
User avatar
bensay
Posts: 202
Joined: Wed Dec 22, 2021 8:14 pm
Location: Danmark
Contact:

Re: [Bug] [Windows] Techdraw error message with special characters in the username

Post by bensay »

Oh, also, good to see other Danes in here
wmayer
Founder
Posts: 20241
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: [Bug] [Windows] Techdraw error message with special characters in the username

Post by wmayer »

git commit ff01905f0b should fix it.

All path names that are stored in a const char* or std::string are supposed to be UTF-8 encoded. For Linux or macOS there is no problem when using std::ifstream or std::ofstream directly (or their open() function) because their file systems are UTF-8 encoded, too.

Only for Windows it's a bit more difficult. For this platform std::ifstream or std::ofstream provide overloaded versions of the constructors and open() functions. One version that accepts a std::string or const char* and another version that accepts a std::wstring or const wchar_t.

In order to properly support unicode the std::wstring/wchar_t variants must be used.

Now to avoid that every time a std::ifstream/std::ofstream is used one has to deal with the platform differences the classes Base::ifstream and Base::ofstream has been added that require a Base::FileInfo for their constructors.

So, writing the line

Code: Select all

Base::ifstream str(Base::FileInfo(myStdString), ...);
works for all supported platforms.
User avatar
wandererfan
Veteran
Posts: 6265
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: [Bug] [Windows] Techdraw error message with special characters in the username

Post by wandererfan »

wmayer wrote: Sat Aug 20, 2022 2:01 pm git commit ff01905f0b should fix it.
Problem fixed before I even read the post! Thank you.
Haavard
Posts: 217
Joined: Wed Feb 17, 2021 10:48 pm

Re: [Bug] [Windows] Techdraw error message with special characters in the username

Post by Haavard »

wmayer wrote: Sat Aug 20, 2022 2:01 pm git commit ff01905f0b should fix it.
Awesome, thanks! :)
Post Reply