Unicode in variables

J. Landman Gay jacque at hyperactivesw.com
Mon Aug 19 16:53:38 EDT 2013


On 8/19/13 3:41 PM, Richard Gaskin wrote:
> Jacque wrote:
>> Basically, I'm storing a glossary. The keys are the glossary terms, some
>> of which are unicode. The definitions are the elements. The user points
>> to a word in a field and I need to retrieve the definition by matching
>> the displayed field text (which is unicodetext) with the glossary key.
>
> I can't find where this is mentioned in the docs, but historically there
> was a caution against using anything but alphanumeric ASCII characters
> for key names.
>
> In my experience that's more strict than it needs to be, but if the
> format of encoded arrays is any clue there may still be a restriction on
> having NULL bytes in a key name.

I'm glad you warned me before I got too far. I've thought of a fallback 
that may work. I am able to convert the entire file into html with some 
silly convolutions. Using a variation on Devin's trick, I'm thinking I 
could get the htmltext of the mousechunk and match *that* against the 
keys, which would also be html.

Might work.

Here's a test script showing how I get the html:

on mouseup -- 3x faster using templatefield
   answer file empty
   if it = "" then exit to top
   put it into tFile
   put url ("file:" & tFile) into tData
   put uniEncode(tData,"UTF8") into tData
   set the unicodetext of the templatefield to tData
   get the htmltext of the templatefield
   replace "<" with "<" in it
   replace ">" with ">" in it
   replace "&bull;" with "•" in it
   set the htmltext of fld 1 to it
end mouseup

We're using a very limited set of html tags, so the three replacements 
in the script are all I need. This largely works except that after I 
split the data, some of the keys are in html. There is also the problem 
of <p> tags around each line but I can deal with that.

If anyone knows a better way to convert to html, I'm all ears.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com




More information about the use-livecode mailing list