🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: cn.bbs.comp.program
Article #1176

string manipulation routines

#1176
From: �ϵ�
Date: Sun, 19 Apr 1998 00:00
105 lines
3019 bytes
������: njhe (heҪ�Ʋ�), ����: RAD
��  ��: string manipulation routines
����վ: '3m�Ͻ�ɺ�m' (Mon Mar  9 18:13:37 1998) , վ���ż�

     Product: Delphi
     Version: All
     Platform: Windows/Win32



Here are some standard string manipulation functions:

{To determine if the character is a digit.}
function IsDigit(ch: char): boolean;
begin
  Result := ch in ['0'..'9'];
end;

{To determine if the character is an uppercase letter.}
function IsUpper(ch: char): boolean;
begin
  Result := ch in ['A'..'Z'];
end;

{To determine if the character is an lowercase letter.}
function IsLower(ch: char): boolean;
begin
  Result := ch in ['a'..'z'];
end;

{Changes a character to an uppercase letter.}
function ToUpper(ch: char): char;
begin
  Result := chr(ord(ch) and $DF);
end;

{Changes a character to a lowercase letter.}
function ToLower(ch: char): char;
begin
  Result := chr(ord(ch) or $20);
end;

{ Capitalizes first letter of every word in s }
function Proper(const s: string): string;
var
  i: Integer;
  CapitalizeNextLetter: Boolean;
begin
  Result := LowerCase(s);
  CapitalizeNextLetter := True;
  for i := 1 to Length(Result) do
  begin
    if CapitalizeNextLetter and IsLower(Result[i]) then
      Result[i] := ToUpper(Result[i]);
    CapitalizeNextLetter := Result[i] = ' ';
  end;
end;

{ NOTE: The following functions are available in Delphi 2.0,
  but not in Delphi 1.0. }

{Supresses trailing blanks in a string.}
function TrimRight(const s: string): string;
var
  i: integer;
begin
  i := Length(s);
  while (I > 0) and (s[i] <= ' ') do Dec(i);
  Result := Copy(s, 1, i);
end;

{Removes the leading spaces from a string.}
function TrimLeft(const S: string): string;
var
  I, L: Integer;
begin
  L := Length(S);
  I := 1;
  while (I <= L) and (S[I] <= ' ') do Inc(I);
  Result := Copy(S, I, Maxint);
end;

{ Removes leading and trailing whitespace from s);
function Trim(const S: string): string;
var
  I, L: Integer;
begin
  L := Length(S);
  I := 1;
  while (I <= L) and (S[I] <= ' ') do Inc(I);
  if I > L then Result := '' else
  begin
    while S[L] <= ' ' do Dec(L);
    Result := Copy(S, I, L - I + 1);
  end;
end;
--
��ϧһ�д�ۣ��ﵽ���������塣
��������߱����������߱��

m;31m�� ��Դ:���Ͻ�ɺ� bbs.njupt.edu.cn��[FROM: 202.119.236.104]m

--
�� ��Դ:���ϴ�С�ٺ���Ϣ����վ bbs.nju.edu.cn��[FROM: a507yjh.nju.edu]
Technical Details
Message-ID: <3OAbTD$t1C@bbs.nju.edu.cn>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: fc86e,9fcfe59cedcdf6c6,start
X-Google-Attributes: gidfc86e,public
From: mendy.bbs@bbs.nju.edu.cn (�ϵ�)
Subject: string manipulation routines
Date: 1998/04/19
Message-ID: <3OAbTD$t1C@bbs.nju.edu.cn>
X-Deja-AN: 345876722
X-Filename: Programming/M.893006461.A
Organization: nju_bbs
Newsgroups: cn.bbs.comp.program