forum.boolean.name

forum.boolean.name (http://forum.boolean.name/index.php)
-   MidletPascal (http://forum.boolean.name/forumdisplay.php?f=46)
-   -   Help...Lib or function to replace String (http://forum.boolean.name/showthread.php?t=13094)

jt2003 07.08.2010 22:07

Help...Lib or function to replace String
 
Hi.

i´ve seen that font32 lib do not accept iso8859-1 chars like ç...
i would need some code help to create a function to replace a string..something like:

str1:="nice day ç";
newstr:=integerToString((CHR(231));
string_replace (str1,"ç",newstr);

any ideias or code samples???

thanks,

cherepets 07.08.2010 22:30

Ответ: Help...Lib or function to replace String
 
you can use russian or for other symbols and replace them in font file *.png.
i made some smiles for chat in my game that way :)

"костыль"

jt2003 09.08.2010 22:18

Ответ: Help...Lib or function to replace String
 
Цитата:

Сообщение от cherepets (Сообщение 157616)
you can use russian or for other symbols and replace them in font file *.png.
i made some smiles for chat in my game that way :)

"костыль"

Hi.

but in that case i "lost" common chars like "abcdef..."; my ideia is:

1-create a txt file as resource
2- load it and create a function ( lib was better) that parse/replace all non readable chars in font32 lib and replace them with their CHR codes...i saw that if i use in font32 lib " some text"+chr(200) it works.... the lib / function would translate those chars that block the APP...

thanks anyway

cherepets 10.08.2010 07:04

Ответ: Help...Lib or function to replace String
 
you won't lose latin chars because you can replace only cyrilic.
i'm sure that you have russian layout in windows, so you can write them as yours.

i mean you will replace russian 'с' with your 'з' in *.png file. after that you will still have english 'c' and if your own 'з' that must be mentioned in code as russian 'c'.

sorry if my explaintion doesn't seem very clear.

abcdef 10.08.2010 10:08

Ответ: Help...Lib or function to replace String
 
Код:

function repls(str, s1, s2 : string) : string;
var
  p,len1 : integer;
begin
  len1 := length(s1);
  repeat
    p := pos(str,s1);
    if (p<0) then break;
    str := copy(str,0,p) + s2 + copy(str,p+len1,length(str));
  until false;
  repls := str;
end;

var
  i : integer;
  s : string;
begin
  s := repls('4501234567890123456789454','45','abcdef');
  showForm;
  i := formAddString('>> '+s);
  repeat until false;
end.


jt2003 14.08.2010 17:23

Ответ: Help...Lib or function to replace String
 
thanks for the code..

Цитата:

Сообщение от abcdef (Сообщение 157850)
Код:

function repls(str, s1, s2 : string) : string;
var
  p,len1 : integer;
begin
  len1 := length(s1);
  repeat
    p := pos(str,s1);
    if (p<0) then break;
    str := copy(str,0,p) + s2 + copy(str,p+len1,length(str));
  until false;
  repls := str;
end;

var
  i : integer;
  s : string;
begin
  s := repls('4501234567890123456789454','45','abcdef');
  showForm;
  i := formAddString('>> '+s);
  repeat until false;
end.



ВиНТ 27.02.2012 05:42

Ответ: Help...Lib or function to replace String
 
IntegerToString() ?


Часовой пояс GMT +4, время: 18:52.

vBulletin® Version 3.6.5.
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Перевод: zCarot