CharToNum Depricated??

Niggemann, Bernd Bernd.Niggemann at uni-wh.de
Tue Sep 17 07:41:42 EDT 2024


Hi Bob,


Actually I think what I need to do is figure out what the original file
encoding is, and use that when I write out the export file.

I assume that the byte order mark (BOM) is for UTF-8

To see the BOM for UTF-8 make a button and a field named "fText"

Use this script for the button

-------------------------------------------------------------
on mouseUp
   local tPath, tContent, tBom, tCollect
   answer file "choose"
   if it is empty then exit mouseUp
   put it into tPath
   if the optionKey is down then
      put url ("binfile:" & tPath) into tContent
      delete line 2 to -1 of tContent
      put textEncode(tContent, "UTF-8") into tContent
   else
      put url ("file:" & tPath) into tContent
      delete line 2 to -1 of tContent
   end if
   put tContent into field "fText"
end mouseUp
-------------------------------------------------------------

and see if you see the BOM when you hold down the option key when opening the file
If you do not use the option key there should be no BOM at the beginning of the text and the text is automatically UTF-8 encoded
Apparently "put url ("file:" & tPath)" is also aware of the encoding of the file since it converts it omits the BOM.

Kind regards
Bernd


More information about the use-livecode mailing list