比如:
     str := '上班了';
    buf  := array [ 1..10] of byte;   我要把str放到buf中,如何处理?

解决方案 »

  1.   

    for i := 1 to Length(str) do
      buf[i] := Ord(str[i]);
      

  2.   

    那如何还原回来呢?把buf[]中的内容还原回str
      

  3.   

    for i := 1 to 10 do
      str := str + chr(buf[i]);
      

  4.   

    楼主有点懒哦!要学着习惯有问题找帮助Returns the character for a specified ASCII value. UnitSystemCategorycharacter manipulation routinesDelphi syntax:function Chr(X: Byte): Char;DescriptionChr returns the character with the ordinal value (ASCII value) of the byte-type expression, X.------------------------------------------------------
    Returns the ordinal value of an ordinal-type expression.UnitSystemCategoryordinal routinesDelphi syntax:function Ord(X);DescriptionX is a Delphi ordinal-type expression. The result is the ordinal position of X; its type is the smallest standard integer type that can hold all values of X's type.Ord cannot operate on Int64 values.