본문 바로가기

Delphi/끄적이기

ASCII Control Characters 제거하기

function DelASCIICtrlChars(AStr: string): string;
const
  ASCII_CTRL_CHARS = [1, 2, 3, 4, 5, 6, 7]; //제거가 필요한 ASCII Control Characters 추가
var
  nChar: Integer;
begin
  Result := AStr;
  
  try
    for nChar in ASCII_CTRL_CHARS do
      Result := Result.Replace(char(nChar), ''); 
  except
  end;
end;

가져온 데이터에 가끔 섞여 있을 때가 있어, 에러를 발생시키 전에 미리 제거하기..

반응형