Jump to content

Pluginapi.h: Incorrect Unicodehandling


Recommended Posts

In the PluginAPI.h file (no version id in the file) the plgName function is declared as returning the type LPCTSTR (long pointer to const T string). As a convenience for porting, the placeholder "T" changes for ANSI, Multibyte, and Unicode builds according to preprocessor definitions.

 

So, the recommended (and common) way to code plgName is this:

 

PLUGIN_API LPCTSTR plgName( void )
{
// called by gui thread - sim thread not running
return TEXT("MySbPlugin"); // app.Name();	
}

 

Unfortunately, that results in the plugin name appearing as the single character "M". I assume this is because the IDE isn't expecting a unicode string, and interprets the second byte returned ('0x0') as an end of string. I tried altering my implementation of plgName to:

 

PLUGIN_API LPCTSTR plgName( void )
{
// called by gui thread - sim thread not running
return (LPCTSTR)"MySbPlugin"; // app.Name();	
}

 

This works fine, and the full name of the plugin appears. The bad news is, at least in unicode builds, that's a bad cast. Basically, if the API isn't expecting unicode strings it shouldn't be using the "T" preprocessor definitions.

 

Thanks,

µ

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...