Converting from unicode to ASCII

Bob Sneidar bobsneidar at
Wed Sep 23 11:08:12 EDT 2020

Will binaryEncode get you back to the filename?

Bob S

On Sep 23, 2020, at 8:03 AM, Richard Gaskin via use-livecode <use-livecode at<mailto:use-livecode at>> wrote:

J. Landman Gay write:

> I'm looking for a way to create non-unicode file names
> based on the string that comes out of the database.

Ah, public clouds...

Amazon's S3 docs say just encoding in UTF-8 should suffice, but then they also list a lot of characters they consider "special", but common usage considers them not so special at all, so conflicts like this are apparently abundant.

One workaround for their storage name limitations I've seen used elsewhere is hash-based names, giving you a string that is plain ASCII, of a fixed and usable length, and is derived from the file name so systems don't need to maintain a lookup table to find the file based on a given string.

This will give you a 40-char string in plain ol' ASCII unique to the input:

   function CleanHash s
      get binaryDecode("h*", sha1Digest(s), tHash)
      return tHash
   end CleanHash


   get CleanHash("MyFile.txt")



More information about the use-livecode mailing list