🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: cn.bbs.comp.program
1 messages
1 total messages Started by �ϵ� Sun, 19 Apr 1998 00:00
string manipulation routines
#1176
Author: �ϵ�
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]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads