function EncodeCNStr(const aStr: string): string;
const
  CharArr: array of Char = ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H',
                            'I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
  function EncodeChar(C: Char): string;
  var
    W: Word;
  begin
    if C in ['a'..'z', 'A'..'Z', '/', '\', '_', '-', '.'] then Exit(C);
    W := Ord(C);
    Result := '';
    while W > 0 do
    begin
      Result := CharArr[W mod 36] + Result;
      W := W div 36;
    end;
  end;
var
  i: Integer;
begin
  Result := '';
  for i := 1 to aStr.Length do
    Result := Result + EncodeChar(aStr[i]);
end;

posted on 2015-12-15 20:41  万一  阅读(209)  评论(0)    收藏  举报