how to convert/delete characters from a text?

If you need help on how to use the program
Post Reply
ABNormal
Posts: 135
Joined: 2005-01-08 08:33:38

how to convert/delete characters from a text?

Post by ABNormal »

is there a way to remove (or substitute) some characters from a field text
in some collected fields i have to "fight" with some "chinese" characters.
Example: Does not have é—´éÂ￾“ (taped)
I'ld like to leave only the "western" part of that text:
Does not have (taped)

logically the function should be:

Code: Select all

oldtxt:=getfield(fieldXYZ);
n:=1;
newtxt:='';
letter:='';
while n<=[i]length(oldtxt)[/i] do begin
letter:= [i]substring(oldtext,n,1)[/i] ;
//valid only between #32 to #165 
if letter<' ' [i].or.[/i] letter > 'Ñ' then letter:='';
newtxt:=newtxt+letter;
end;
Antoine may you help me to write it in a correct way, please?

thank you
ABN
antp
Site Admin
Posts: 9720
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Why 165? Basic ASCII characters stop at 127.

Code: Select all

program NewScript;
var
  s: string;
  i: Integer;
  Result: string;
begin
  s := 'Does not have é—´éÂ￾“ (taped)';
  Result := '';
  for i := 1 to Length(s) do
    if (StrGet(s, i) >= #32) and (StrGet(s, i) <= #127) then
      Result := Result + StrGet(s, i);
  ShowMessage(Result);
end.
Post Reply