Text (uni)coding issue

Mike Kerner MikeKerner at roadrunner.com
Sat Aug 26 08:50:36 EDT 2017

Any reason why you're using binfile instead of file if the text isn't

On Sat, Aug 26, 2017 at 8:34 AM, Andrew Bell via use-livecode <
use-livecode at lists.runrev.com> wrote:

> I have a database on a LiveCode server that I use to track user
> interactions in a LiveCode app. It has gotten too big to query in LiveCode
> without timeout errors (the JSON gets mangled because there are now several
> thousand records), so I'm trying to generate a text file on the server and
> download that instead.
> I can get the text file to generate on the server, but when I try to
> download it to my LiveCode app (to eventually save on the end-users
> computer) the text is in some weird format. I assumed this was some wierd
> unicode issue and tried to textDecode it, but can't seem to figure out what
> format it actually is so that just gives me text in a different weird
> format ("UTF-8", "UTF-16", and "MacRoman" don't seem to work).
> My code on the LiveCode Server seems straight forward:
>   put "SELECT * FROM promosRedeemed" into tSql
>   put revDataFromQuery(TAB, "|", sDbId, tSql) into tRedemptions
>   set linedelimiter to "|"
>   set itemdelimiter to tab
>   replace RETURN with " -=- " in tRedemptions // ACCOUNTS FOR LINE BREAKS
>   replace "|" with RETURN in tRedemptions
>   put "redemption-log_" & the seconds & ".txt" into tFileName
>   open file specialFolderPath("home") & "/public_html/server/apps/iot/logs/"
> & tFileName for write
>   write tRedemptions to file specialFolderPath("home") &
> "/public_html/server/apps/iot/logs/" & tFileName
>   close file specialFolderPath("home") & "/public_html/server/apps/iot/logs/"
> & tFileName
> The first line of the text file when viewed in a web browser or text file
> downloaded directly (outside of LC) is plain text and looks as expected:
> 294     Wednesday, July 13, 2016 8:36   15      3       MacOS 10.11.5 -=-
> MacBookPro11,3 -=- 0,0,1920,1200 -=-  39.892219,-85.974632
> But when I fetch that URL in LiveCode using...
>  put url (tURLtoDownload) into tFullRedemptionList
>  put tFullRedemptionList into url ("binfile:Full-IOT_TSM_Redempt
> ionList.xls")
> ...the first line (and all other lines basically) looks like this:
> ã        ‰Ω◊rÎ:∂(˙Ï˝ <un›ó≥<7rp≠ªÎ:Áú˝‚bîsí ø˛ $@B H[≤<Â∂ª´´zyA   ¿»
> L∞ˇF¸ø! ÿ D¡÷˙ ï x‚¸Óψ&˝G˛¡ ‡   ∏dXí ÇIAˇ ц† Í?ˇ ’Ø°¸o  õÄr NÄâ¸Ôh M
> ıôı0fi‹˝ Ç? ˛!≈ø¬   Áˇ ê +è7Å˛e ≈ ïSP ˇ ®ˇ‘˝êx~(ß Pø5?Ñ–ˇKÍ˝%eS ô_ ˇ ŸƒnÿQ?
> Œ — bSHò  ˇ π˜á N·w6)¸?T iÛ •ˇá≤¢NÕ !–g(Ù
> Ä˙ ‘
> ®[      ùïàÎïu á»YäÅ^ZCbà›ïX؃5+IπR*ä ”Î ≤f%uW
> I know I've done similar tasks before (pretty sure this is code I borrowed
> from other projects I've done) but can't figure out why this text is so
> garbled. Tried in 9.0.0dp7 and 8.1.6 with the same result. Any ideas what
> I'm doing wrong?
> --Andrew Bell
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."

More information about the Use-livecode mailing list