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:



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