Pascal Scripting: StringChangeEx
Prototype:
function StringChangeEx(var S: String; const FromStr, ToStr: String; const SupportDBCS: Boolean): Integer;
Description:
Changes all occurrences in S of FromStr to ToStr. If SupportDBCS is True (recommended unless you require binary safety), double-byte character sequences in S are recognized and handled properly. Otherwise, the function behaves in a binary-safe manner. Returns the number of times FromStr was matched and changed.
Remarks:
When working with strings containing paths or filenames, be sure to pass True in the SupportDBCS parameter. Otherwise, paths with Chinese, Japanese, or Korean characters may be corrupted.
Example:
var S: String; begin S := ExpandConstant('{commonappdata}'); // S = 'C:\Documents and Settings\All Users\Application Data' StringChangeEx(S, '\', '/', True); // S = 'C:/Documents and Settings/All Users/Application Data' end;