escaping line breaks in string

Short of writing my own method to do this, is there something built into Xojo that will meet the following specification (the filepath they refer to will be a native path as a string at the point where I’m manipulating it):

[quote] o If a filepath includes a Line Feed (LF), a Carriage Return (CR),
a Carriage-Return Line Feed (CRLF), or a percent sign (%), those
characters (and only those) MUST be percent-encoded following
[RFC3986].[/quote]

EncodeURLComponent does this, but it also escapes spaces and everything else, which is not what I’m supposed to do here. I’m hoping there’s something built-in before I write some custom code to do this, but I can’t find anything that lets me specify specific characters to escape.

I’m on Xojo 2017r3

Thanks!

s=replaceall(s,"%","%%")
s=replacelineendings(s,"%0A")

Just keep in mind that Dave’s suggestion works if you don’t mind replacing CRLF and CR with a LF in the encoding. Otherwise, you will need two ReplaceAll calls instead of ReplaceLineEndings.

You could search for &u0A and &u0D (or Chr(10) and Chr(13)) and replace with “%0A” and “%0D” respectively.