All pastes #742567 Raw Edit

Something

public text v1 · immutable
·published 2007-10-19 17:09 UTC
rendered paste body
function utf2asc(s:string): string;
var
  t:string;
  i:integer;
begin
  i:=1;
  t:='';
  while i<=length(s) do begin
    if ord(s[i])<128 then t:=t+s[i]
    else begin
      t:=t+chr(((ord(s[i]) and 3)*64)+(ord(s[i+1]) and 63));
      i:=i+1;
    end;
    if t[length(t)]=#0 then t[length(t)]:=#255;
    i:=i+1;
  end;
  Result:=t;
end;