
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@655 8e941d3f-bd1b-0410-a28a-d453659cc2b4
53 lines
1015 B
ObjectPascal
53 lines
1015 B
ObjectPascal
unit fpsutils;
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
interface
|
|
|
|
uses
|
|
Classes, SysUtils;
|
|
|
|
function WordToLE(AValue: Word): Word;
|
|
function DWordToLE(AValue: Cardinal): Cardinal;
|
|
function IntegerToLE(AValue: Integer): Integer;
|
|
|
|
implementation
|
|
|
|
{
|
|
Endianess helper functions
|
|
|
|
Excel files are all written with Little Endian byte order,
|
|
so it's necessary to swap the data to be able to build a
|
|
correct file on big endian systems.
|
|
}
|
|
|
|
function WordToLE(AValue: Word): Word;
|
|
begin
|
|
{$IFDEF BIG_ENDIAN}
|
|
Result := ((AValue shl 8) and $FF00) or ((AValue shr 8) and $00FF);
|
|
{$ELSE}
|
|
Result := AValue;
|
|
{$ENDIF}
|
|
end;
|
|
|
|
function DWordToLE(AValue: Cardinal): Cardinal;
|
|
begin
|
|
{$IFDEF BIG_ENDIAN}
|
|
// ?? Result := ((AValue shl 8) and $FF00) or ((AValue shr 8) and $00FF);
|
|
{$ELSE}
|
|
Result := AValue;
|
|
{$ENDIF}
|
|
end;
|
|
|
|
function IntegerToLE(AValue: Integer): Integer;
|
|
begin
|
|
{$IFDEF BIG_ENDIAN}
|
|
// ?? Result := ((AValue shl 8) and $FF00) or ((AValue shr 8) and $00FF);
|
|
{$ELSE}
|
|
Result := AValue;
|
|
{$ENDIF}
|
|
end;
|
|
|
|
end.
|
|
|