Detect and remove Byte order mark
So in FileMaker, you can read text as UTF-8, detect the BOM character and remove it for further processing:
# Read text as UTF-8
Set Variable [$text; Value: MBS("CURL.GetResultAsText"; $curl; "UTF-8")]
# get first character
Set Variable [$c; Value:Code(Left($text; 1))]
# is it the UTF-8 BOM?
If [$c = 65279]
# remove it
Set Variable [$text; Value:Middle($text; 2; Length($text)-1)]
End If
# now use the text
Set Field [CURL Test::Text; $text]
At any time you can create the BOM character for UTF-8 with Character(65279) and put it in front of text, before sending it via plugin functions to a file, a socket, a server or a serial port.