SA-MP Forums Archive
[HELP] Using str_ireplace to leach Special Charakters out of a string - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] Using str_ireplace to leach Special Charakters out of a string (/showthread.php?tid=104193)



[HELP] Using str_ireplace to leach Special Charakters out of a string - kony1994 - 23.10.2009

Hello Commnunity,

I had a Problem with my chat, becouse this chat works with textrdraws and in textdraws dont work Special Charakters.
At

Код:
public OnPlayerText(playerid, text[])
I want to leach the "text" string and gives out the formatted, i already have that:
Код:
new texttring[128];
	
	
	new from[][] = {
  "д",
  "ь",
  "ц",
	"Я"
}
	new to[][] = {
  "ae",
  "ue",
  "oe",
	"sz"
}
format(texttring,128,"%s",str_ireplace(from[], to[], text));
	
	SendMessage(i,texttring);
But it doeasent work, just ae or just ue gives out, anybody can help me?

(sry for shit english, iam german)

Iknow in english are not so oft usen this special chraktwers, but help me pls.

Thankyou!

(sry for shit english, iam german)



Re: [HELP] Using str_ireplace to leach Special Charakters out of a string - Westie - 23.10.2009

str_ireplace doesn't support arrays. You'll have to replace seperately.


Re: [HELP] Using str_ireplace to leach Special Charakters out of a string - kony1994 - 23.10.2009

can you ive me maybe an example? I then do it myself, just an example

/edit or can you give me the str stock, that works with arrays?


Re: [HELP] Using str_ireplace to leach Special Charakters out of a string - Google63 - 23.10.2009

You can do like this:

Код:
stock removeChars(from[], char_array[])
{
  new 
    from_ptr[];

  for(new x = 0, o = 0, y = 0; from[x] != EOS; x++)
  {
    while(char_array[o++])
      if(from[x] == char_array[o])
       continue;
    from_ptr[y++] = from[x];
    o = 0;
  }
}
This should work, but not tested :P

edit: sry i didn't saw that you need to replace, not to remove; ignore this :P