Skip to content

Commit

Permalink
Merge pull request #459 from ollydev/string-convert
Browse files Browse the repository at this point in the history
Export UTF8Encode and UTF8Decode.
  • Loading branch information
MerlijnWajer authored Nov 8, 2018
2 parents 839fc21 + f708ab5 commit ac0f218
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Units/MMLAddon/Imports/script_import_string.pas
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ procedure Lape_IsStrInArr(const Params: PParamArray; const Result: Pointer); {$I
PBoolean(Result)^ := IsStrInArr(PString(Params^[0])^, PBoolean(Params^[1])^, PStringArray(Params^[2])^);
end;

procedure Lape_UTF8Decode(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PWideString(Result)^ := UTF8Decode(PString(Params^[0])^);
end;

procedure Lape_UTF8Encode(const Params: PParamArray; const Result: Pointer); {$IFDEF Lape_CDECL}cdecl;{$ENDIF}
begin
PAnsiString(Result)^ := UTF8Encode(PWideString(Params^[0])^);
end;

procedure Lape_Import_String(Compiler: TLapeCompiler; Data: Pointer);
begin
with Compiler do
Expand Down Expand Up @@ -147,6 +157,8 @@ procedure Lape_Import_String(Compiler: TLapeCompiler; Data: Pointer);
addGlobalFunc('function IsArrInStr(constref Arr: TStringArray; S: String): Boolean;', @Lape_IsArrInStr);
addGlobalFunc('function IsStrInArr(S: String; const UsePos: Boolean; const Arr: TStringArray): Boolean;', @Lape_IsStrInArr);
addGlobalFunc('function PosMulti(const SubStr: String; Text: String): TIntegerArray;', @Lape_PosMulti);
addGlobalFunc('function UTF8Decode(constref S: AnsiString): WideString;', @Lape_UTF8Decode);
addGlobalFunc('function UTF8Encode(constref S: WideString): AnsiString;', @Lape_UTF8Encode);
end;
end;

Expand Down

0 comments on commit ac0f218

Please sign in to comment.