2023-02-06 02:04 PM - edited 2023-02-06 02:07 PM
Hello dear Graphisoft Community,
I'm currently writing an AddOn to rename layouts, but im getting trouble with special characters.
We work in german and special chars like "äöüß" are part of our projects.
To rename the layouts, i read from a csv file the old and new ref and name (https://archicadapi.graphisoft.com/documentation/api_windowinfo for reference) and rename if i find a match. This part works fine, but as soon as a layout consists of special charaters, everything goes bad:
This is how the data looks after reading it from the .csv (i read the file with fstream and every string is saved as std::string inside a vector). Everytime there is a special characters, I only get ????????.
This also stays after renaming the layouts:
But as you can see, special characters work just fine (like Ü).
So I'm not sure what causes the behavior, most likely it is how I convert std::string to GS::uchar_t
I've tried (note - csvInfos[ev.GetListItem() - 1] returns a std::string):
str1 = GS::UniString(std::get<0>(csvInfos[ev.GetListItem() - 1]).c_str(), CC_UTF8)
str1 = tb.ToUniString(tb.StringToWString(std::get<2>(csvInfos[ev.GetListItem() - 1])))
(from https://community.graphisoft.com/t5/Developer-forum/Convert-from-GS-UniString-to-std-string/td-p/306...)
and some other things, which didn't work.
The above code was for displaying the old and new values in a list.
for the renaming part I tried the same things as for the list and
But nothing works.
Can anyone give me a tip on how to work with special characters in ArchiCAD or how I can properly convert std::string to GS::uchar_t?
2023-02-06 03:01 PM
Well, I found a solution...
Turns out my csv-File wasn't utf-8. After exporting my csv to utf-8, it worked like a charm.
2023-02-06 03:13 PM
Hi, i am from Brazil and i went through something really similar when trying to write strings like "construção", "métodos", etc. I solved it by using a GS::UniString object with the macro L( ) inside it. Something like this:
GS::UniString name {L("Construção")}; // Ok
GS::UniString name_2 {"Construção"}; // Results in ??????????
I found this solution in some of the SDK examples. I don't know if the special characters you mentioned will work with this method, but you can give it a shot.
2023-02-10 12:47 PM
Hey, thanks for the suggestion, but this method doesn't work for me since i don't know the strings during compile time and you can't do things like {u8(stringVariable)}