Language convenience rant...

Paul Dupuis paul at
Fri Sep 27 12:26:26 EDT 2019

Assume I have a function guessTextEncoding that returns the various 
possible encoding for a text file.

If the file is MacRoman and my app is running on OSX (Platform() = "MacOS")
I can use:
put URL ("file:"&tFile) into tText
put textDecode(tText,"Native") into ... destination
put textDecode(tText,"MacRoman") into ... destination

Howeever if I have a MacRoman encoded text file (moved from OSX to 
Window via USB Memory stick or however) and my app is running under Windows

put textDecode(tText,"MacRomam") into ... destination

Throws a script error as MacRoman as an encoding parameter for the 
function is, as stated in the documentation, OSX ONLY, so instead I have to

put URL ("file:"&tFile) into tText
put macToIso(tText) into ... destination

And conversely the same is true with a CP1252 encoded file under Windows
put URL ("file:"&tFile) into tText
put textDecode(tText,"Native") into ... destination
put textDecode(tText,"CP1252") into ... destination
both are good, but for a CP1252 encoded text file under OSX...
put textDecode(tText,"CP1252") into ... destination
throws an error, and so you have to use

put URL ("file:"&tFile) into tText
put isoToMac(tText) into ... destination

You would think that SINCE the engine knows the platform AND the 
isoToMac and macToIso functions exists in the engine regardless of 
platform, that LiveCode, Ltd could have made:

put textDecode(tText,"MacRomam") into ... destination WORK under Windows
put textDecode(tText,"CP1252") into ... destination WORK under OSX

So that instead of a SWITCH statements or a bunch of if-the-elses based 
on the results of a guessTextEncoding(tFile) function, you could just do:

put guessTextEncoding(tFile) into tEncoding
put URL ("file:"&tFile) into tText
put textDecode(tText,tEncoding) into ... destination!

Enhancement request:

More information about the use-livecode mailing list