Read text file from a script for search & replace

What would be the preferred way to read a text file —specifically an XML document— from a button script to make some regex search and replace operations and then save the results?

FSUtil.OpenFile can open a file and access its contents as binary data, but I can't find anything similar for text files which may have different encodings. I know I could use StringTools.Decode by passing the Blob object generated with the previous method, but I would have to know in advance the encoding used, right? Any other way?

Windows has built in helpers for reading and writing text files:

OpenTextFile: https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/windows-scripting/314cz14s(v%3Dvs.84)

CreateTextFile: https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/windows-scripting/5t9b5c0c(v=vs.84)

(You'll still implicitly need to know which encoding is used.)