function SetToStr(TypeInfo: PTypeInfo; const Value; Brackets: Boolean = True): string;
type
 ByteSet = set of 0..7;
var
 ByteValue: ^ByteSet;
 I, M: Integer;
 ElemTypeInfo: PTypeInfo;
 ElemTypeData: PTypeData;
begin
 Result := '';
 ElemTypeInfo := GetTypeData(TypeInfo)^.CompType^;
 ElemTypeData := GetTypeData(ElemTypeInfo);
 ByteValue := @Value;
 for I := ElemTypeData^.MinValue to ElemTypeData^.MaxValue do
 begin
  M := I mod 8;
  if M in ByteValue^ then
  begin
   if Result <> '' then
    Result := Result + ',';
   Result := Result + GetEnumName(ElemTypeInfo, I);
  end;
  if M = 7 then Inc(ByteValue)
 end;
 if Brackets then
  Result := '[' + Result + ']';
end;