Char Set on Custom Properties

Mark Waddingham mark at livecode.com
Fri Sep 4 08:57:39 EDT 2015


On 2015-09-03 21:38, J. Landman Gay wrote:
> Returning to this topic...we are in the process of creating new stacks
> in LC 7 while still running older LC 6 stacks with the same app.
> Stacks have custom properties containing text created on a Mac, and my
> app uses MacToISO() to display the text when running on Windows.
> 
> Some of the LC 6 stacks will be edited and saved in LC 7, others will
> remain as LC 6 for a while. My app needs to know whether the character
> set has already been converted so it can display text correctly. Is
> there a way to tell in a script?

Hmmm - this is somewhat tricky.

 From what you are saying you want people to be able to edit content in 
both LC6 and LC7, the content itself being saved in LC6 format. i.e. You 
want to move your system forward to LC7, but you need to still support 
LC6 clients and editors. Is that correct?

Now, LC7 will assume that custom property values coming from LC6 format 
stacks are binary data thus won't do anything magical with them. 
However, as soon as you pass that value through anything text-related in 
LC7 and set the custom property back, it will be (in memory at least) 
stored as text. Then, when you save the stackfile in LC6 format the 
engine will convert the text to the platform encoding and save as binary 
(which is what LC6 expects).

Of course, having just written that there might not be a problem here. 
If you are still intending to save all your stacks in LC6 format then it 
should be fine. You still need to do macToIso / isoToMac in LC7 since it 
will only be loading things in LC6 format - a problem would only arise 
if you were sometimes saving your content stacks in LC7 format.

In terms of moving forward what you might want to consider is 
transitioning to storing your text in custom properties in UTF8 format. 
So, rather than using macToIso / isoToMac you decode the UTF8 into text 
in both LC6 and LC7. This means you can continue to use LC6 format, but 
at some point in the future ditch LC6 support and then you'll be able to 
start using unicode in your text without any problems. (To be fair, you 
could still do that now - its just that in LC6 clients / editors, any 
unicode characters would appear as ? as they wouldn't be in the native 
encoding).

Hopefully that's not too confusing :S

Mark.

-- 
Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps




More information about the use-livecode mailing list