I use a script for title updates to our RDS encoder, but the : and / character are reserved for special purposes apparently… So I need to escape them when they exist in an artist/title. So : needs to become : and / needs to become /. Any ideas how to do this? I tried the Delphi function StringReplace but mAirList doesn’t know that unfortunately…
var
Oldstring, Newstring, Part: string;
i: integer;
begin
Newstring := '';
for i := 1 to Length(Oldstring) do
begin
Part := Copy(Oldstring, i, 1);
if Part = ':' then
Part := '\:'
else if Part = '/' then
Part := '\/';
Newstring := Newstring + Part;
end;
end.
Oldstring derives from the function extracting the title string, Newstring is the escaped title to be sent to the encoder.
The whole thing can be packed into a function, like this:
function Escape(Oldstring: string): string;
var
Newstring, Part: string;
i: integer;
begin
Newstring := '';
for i := 1 to Length(Oldstring) do
begin
Part := Copy(Oldstring, i, 1);
if Part = ':' then
Part := '\:'
else if Part = '/' then
Part := '\/';
Newstring := Newstring + Part;
end;
Result := Newstring;
end;
This function can be called within the script from which the title string is generated:
var
Title: string;
function Escape(Oldstring: string): string;
// (everything from above)
procedure OnPlayerStart(PlaylistIndex: integer; PlayerIndex: integer; Item: IPlaylistItem);
begin
Title := Escape(Item.GetTitle);
end;
begin
end.