Gamestudio Links
Zorro Links
Newest Posts
Z9 getting Error 058
by madpower2000. 07/22/26 10:56
ZorroGPT
by TipmyPip. 07/21/26 17:54
New Zorro version 3.11
by jcl. 07/21/26 13:42
Lapsa's very own thread
by Lapsa. 07/18/26 13:40
Purchase A8 full licence version
by ukgamer. 07/17/26 05:52
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
3 registered members (madpower2000, TipmyPip, VoroneTZ), 1,571 guests, and 19 spiders.
Key: Admin, Global Mod, Mod
Newest Members
riggi89, shuhari, KD1990, Ephraim, Student_64151
19223 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
STRING* and external plugins #323061
05/11/10 13:17
05/11/10 13:17
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline OP
Serious User
Dark_samurai  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Hi!

Since A7.84, STRING* doesn't work correct with my external plugins anymore. A short example:

Lite-C:
Code:
void main()
{
   STRING* test_str = str_create("#10");
   str_cpy(test_str,"TEST");
   exSample_function(test_str);
}



c++:
Code:
DLLFUNC void exSample_function(STRING* str)
{
   char str_as_char[10];

   strcpy(str_as_char,str->chars);
   //str_as_char is NOT filled with the correct content
   //only with random symbols
}



I guess this is because of the migration of the engine to UNICODE. But shouldn't ->chars still return a normal ASCII character set?
How should this be done now?

Thanks for your help!


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: STRING* and external plugins [Re: Dark_samurai] #323062
05/11/10 13:18
05/11/10 13:18
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Have you tried to convert to char with "_chr" ?


Always learn from history, to be sure you make the same mistakes again...
Re: STRING* and external plugins [Re: Uhrwerk] #323066
05/11/10 13:25
05/11/10 13:25
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline OP
Serious User
Dark_samurai  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Yes, it doesn't work either.


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: STRING* and external plugins [Re: Dark_samurai] #323084
05/11/10 14:37
05/11/10 14:37
Joined: Aug 2000
Posts: 1,141
Baunatal, Germany
Tobias Offline

Moderator
Tobias  Offline

Moderator

Joined: Aug 2000
Posts: 1,141
Baunatal, Germany
Are you used to using the VC++ debugger? With it you should see in a minute if the string->chars is wrong or not. Im also using strings in a DLL and they are working as before.

BTW, that "#10" makes not sense in lite-C, it was for WDL where strings had fixed lengths, in lite-C strings need not be defined with a default length, you can just create an empty string with "".


Re: STRING* and external plugins [Re: Tobias] #323086
05/11/10 14:42
05/11/10 14:42
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
What about using wchar_t? This would even make your plugin support unicode. wink

Re: STRING* and external plugins [Re: Lukas] #323132
05/11/10 19:36
05/11/10 19:36
Joined: Aug 2000
Posts: 1,141
Baunatal, Germany
Tobias Offline

Moderator
Tobias  Offline

Moderator

Joined: Aug 2000
Posts: 1,141
Baunatal, Germany
I think wchar_t is necessary only when its an unicode string, but ASCII strings have char*.

Re: STRING* and external plugins [Re: Tobias] #323133
05/11/10 19:39
05/11/10 19:39
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
Try to use a global string.

Re: STRING* and external plugins [Re: FBL] #323147
05/11/10 20:13
05/11/10 20:13
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
Quote:
I think wchar_t is necessary only when its an unicode string, but ASCII strings have char*.


Yes, and if I undesrtood Dark_Samurai's problem right, then trying to use char with the STRINGs that now support unicode returns gibberish. That sounds to me like the strings are now always in Unicode and the chars now contain the bytes which are actually pairs in Unicode. That's why I think the problem can be solved with wchar_t.

Re: STRING* and external plugins [Re: Lukas] #323162
05/11/10 21:37
05/11/10 21:37
Joined: Aug 2000
Posts: 1,141
Baunatal, Germany
Tobias Offline

Moderator
Tobias  Offline

Moderator

Joined: Aug 2000
Posts: 1,141
Baunatal, Germany
Yes, but you can see in the debugger if a STRING contains unicode or not.

With Unicode, the chars pointer is an array that looks like this: 00 41 00 42 00 43...00 00. every second byte is 00. But this is only for unicode strings, normal strings just look as before: 41 42 43... 00.

Re: STRING* and external plugins [Re: Tobias] #323262
05/12/10 18:07
05/12/10 18:07
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
Yes and using wchar_t it would be 0041 0042 0043...0000, as two bytes would be one number.
But I think I understand now what you meant. If each second byte is zero, the char array should seem emtpy instead of containing gibberish.

Page 1 of 2 1 2

Moderated by  old_bill, Tobias 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1