[HELP] Using str_ireplace to leach Special Charakters out of a string
#1

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)
Reply
#2

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

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?
Reply
#4

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)