• Advertisement
Sign in to follow this  

Problem with strings

This topic is 1649 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been working on an awesomium app, and have run into a bit of a problem with strings.
Here's an example
int currentconfig = configsHandle->currentConfig;
char gamedir[260];
//_snprintf(gamedir, sizeof(gamedir),"$('#gamedata0').val('%s');",configsHandle->m_Configs[currentconfig]->m_gamedir);
_snprintf(gamedir, sizeof(gamedir),"$('#gamedata0').val('%s');","f:\\\\what\\\\the\\\\f#$&.fgd");
//printf("the gamedir is: %s\n",gamedir);
MessageBoxA(0,gamedir,"message",MB_OK);
caller->ExecuteJavascript(WSLit(gamedir),WSLit(""));
My problem is this, f:\\\\what\\\\the\\\\f#$&.fgd evaluates to f:\\what\\the\\f#$&.fgd for the messagebox, while on the html element #gamedata0 it shows up as f:\what\the\f#$&.fgd
 
How would i go about getting configsHandle->m_Configs[currentconfig]->m_gamedir converted to something that will show up correctly in the html?

Share this post


Link to post
Share on other sites
Advertisement

Since 4 slashes translates to 2 in what looks like C (or C++), and then translates to 1 in HTML, perhaps it is because storing in gamedir stores 2 slashes next to each other instead of 4 because the slash is an escape character, and when passed along, it looks like second escape set, so it escapes it again.

 

\\\\ -> \\
\\ -> \

Share this post


Link to post
Share on other sites

Which is why a / should be used as a path separator whenever possible (yes, even on Windows). There are extremely few cases where it won't work.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement