Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[?] Filtering out character '\n' in a string

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
talkerzero
Grandmaster Cheater
Reputation: 1

Joined: 24 Jul 2008
Posts: 560
Location: California

PostPosted: Fri Mar 20, 2009 4:55 pm    Post subject: [?] Filtering out character '\n' in a string Reply with quote

Here's Irwin's code..
Code:
VOID FilterString(__in_z LPCTSTR lpcszFilterString, __in TCHAR tch, __out_z LPTSTR lpszBuffer)
{
  TCHAR tchUpper = _totupper(tch);
  UINT  i = 0;

  for (; i < _tcslen(lpcszFilterString); i++)
    if (_totupper(lpcszFilterString[i]) != tchUpper)
      lpszBuffer[i] = lpcszFilterString[i];
  lpszBuffer[i] = _T('\0');
}

So I used..
Code:
FilterString(szScript, '\t', szScriptAll);

szScriptAll should have been "nn", but instead, it's..
Code:
n
n


I can't filter '\n' for some reason, but I can filter every other character. Help?
Back to top
View user's profile Send private message Visit poster's website
slippppppppp
Grandmaster Cheater
Reputation: 0

Joined: 08 Aug 2006
Posts: 929

PostPosted: Fri Mar 20, 2009 5:16 pm    Post subject: Reply with quote

Code:
char* FilterCharacter( char* szSrc, const char* Filter ) {
   char* szReturn = new char[500];
   char* szToken = strtok( szSrc, Filter );
   while( szToken != NULL ) {
      strcat( szReturn, szToken );
      szToken = strtok( NULL, Filter );
   }
return szReturn;
}


I have no idea if it works, i coded it off the top of my head.
Back to top
View user's profile Send private message AIM Address MSN Messenger
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Fri Mar 20, 2009 6:06 pm    Post subject: Reply with quote

Irwin's posted code was wrong. Here's the fix that i applied:

Code:
VOID FilterCharacter(__in_z LPCTSTR lpcszFilterString, __in TCHAR tch, __out_z LPTSTR lpszBuffer)
{
  TCHAR tchUpper = _totupper(tch);
  UINT  i = 0, pos = 0;

  for (; i < _tcslen(lpcszFilterString); i++)
    if (_totupper(lpcszFilterString[i]) != tchUpper)
      lpszBuffer[pos++] = lpcszFilterString[i];
  lpszBuffer[pos] = _T('\0');
}


FilterCharacter("t\testt\tes\tstt\test", '\t', buffer);

and

FilterCharacter("tes\nts\nttes\nt", '\n', buffer);

work perfectly fine.
Back to top
View user's profile Send private message
talkerzero
Grandmaster Cheater
Reputation: 1

Joined: 24 Jul 2008
Posts: 560
Location: California

PostPosted: Fri Mar 20, 2009 6:25 pm    Post subject: Reply with quote

Hmm, interesting.. in a multi-line text box, is a new line (hitting the return key) interpreted as a '\n'?
Back to top
View user's profile Send private message Visit poster's website
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Fri Mar 20, 2009 6:28 pm    Post subject: Reply with quote

talker0 wrote:
Hmm, interesting.. in a multi-line text box, is a new line (hitting the return key) interpreted as a '\n'?


Probably.. convert the string to hex and check.

\n = 0x10 = Line Feed
Back to top
View user's profile Send private message
jackyyll
Expert Cheater
Reputation: 0

Joined: 28 Jan 2008
Posts: 143
Location: here

PostPosted: Fri Mar 20, 2009 11:40 pm    Post subject: Reply with quote

It may be represented by \r\n instead, and that could be the problem.
Back to top
View user's profile Send private message AIM Address MSN Messenger
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Sat Mar 21, 2009 10:39 am    Post subject: Reply with quote

It's represented as \r\n.
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
talkerzero
Grandmaster Cheater
Reputation: 1

Joined: 24 Jul 2008
Posts: 560
Location: California

PostPosted: Sat Mar 21, 2009 12:23 pm    Post subject: Reply with quote

Yup.. worked after I filtered out both \r and \n. Thanks Smile
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites