On 31 Aug 2017, at 8:53 am, Cannon Smith via 4D_Tech <[email protected]> wrote: > > I’m having trouble with saving Unicode characters to a file. For example, the > following code saves a file to disk: > > C_TEXT($tText;$tFilepath) > > $tText:=“©” //Copyright symbol > $tFilepath:=System folder(Desktop)+"test.txt" > TEXT TO DOCUMENT($tFilepath;$tText;UTF8 text without length) > > When I open the file again, it only contains a “?” character. > > If I use: > > TEXT TO DOCUMENT($tFilepath;$tText) > > it saves correctly, but then the file has a BOM character at the beginning > which is wreaking havoc with other systems that aren’t expecting it. > > Does anyone know what I should be doing here? Thanks.
Hi Cannon The first thing I notice is that you are using the old BLOB to text and TEXT TO BLOB constant (UTF8 text without length) with the TEXT TO DOCUMENT command. This command uses either strings such as "UTF-8" or the corresponding MIBEnum ID (the documentation for CONVERT FROM TEXT lists these out). The UTF8 text without length constant has a value of 6 which corresponds to ISO-8859-3 using MIBEnum IDs. Also I'm pretty sure if you use TEXT TO DOCUMENT to produce UTF-8 (or any other charset that has a BOM specified for it), 4D will insert the BOM in the document. So you could use CONVERT FROM TEXT with the "UTF-8" charset to create a BLOB (which won't have the BOM) and then BLOB TO DOCUMENT to write the BLOB to disk Regards Justin ********************************************************************** 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4d.com/archives.html Options: http://lists.4d.com/mailman/options/4d_tech Unsub: mailto:[email protected] **********************************************************************

