Unicode and revBrowser: "selected" property and callback messages

Slava Paperno slava at lexiconbridge.com
Sun May 29 08:37:17 EDT 2011


Thanks for thinking about this, Jacqueline. The problem persists.

I said:
> > When a user double-clicks a word in the revBrowser window, I would like
a message
> to be sent by revBrowser to the stack, with that word as a parameter.

And you said:
> Your best bet is to put in a feature
> request in the QCC, but of course you probably don't want to wait.

I also said:
> > As a slightly different approach, I thought I might tell the user to
> select a word in the Web page that is displayed by revBrowser, and then
> click a button in the card. That would be less intuitive for the user, but
> still practical. So I put this script in the button's mouseUp handler:
> >
> > get revBrowserGet(gBrowserID, "selected")
> > put uniEncode(it, "UTF8") into locSelectedText
> > set the unicodeText of field "BrowserSelection" of this card to
locSelectedText
> >
> > The last line of this script works fine when the selected text is
> > English. When it is Russian, a question mark is received in each
character of
> > "it."

And you said:
> The first thing I'd try is not uniEncoding the string at all. If the
> browser is showing it correctly it may already be UTF-16, and any
> further conversion would corrupt it. If that's true, then the method I
> posted before should be all you need. Just grab the string, prepare the
> field to accept unicode, and set the unicodetext of the field to the
> string.

And I said: I have tried all sorts of combinations of uniEncoding and
uniDecoding everything around this process. When I examine the English
characters in the string returned by the "selection" property, I conclude
that it is in a single-byte charset. For example, when the string АБВABC is
selected in revBrowser display, this call:

get rebRbrowserGet(gBrowserID, "selected")
answer char 1 to 6 of it

displays this:

???ABC

That tells me that "it" is not in UTF-16. If it is indeed in ANSI (or, worse
yet, ASCII), then the question marks are entirely natural: as I said,
applications that are non-Unicode compliant have always done that. But since
the Web page in revBrowser has the meta tag that says:

meta http-equiv="Content-Type" content="text/html;charset=UTF-8"

The browser should know it is a double-byte text. The question is, does its
"selected" property know that? If you have evidence this is otherwise,
please let me know.

You also said:
> If that doesn't work... 
>    put uniEncode(it,"Unicode") into locSelectedText

That is different from what I have done only in that you suggest "Unicode"
where I use "UTF8". Changing that to your version hasn't made a difference.
I think the problem is the content of the "selected" property--but I've only
been playing with LC for a couple of weeks, so I can't trust myself.

You kindly said: 
> And if that doesn't work, I can try to find out why.

I would appreciate any other pointers... Perhaps I am thinking in the
Director box, andthere is a natively LC way to achieve what I need?

Slava

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







More information about the use-livecode mailing list