On 5/29/11 12:21 AM, Slava Paperno wrote:
When I save my Unicode files as UTF-8 text (from the Windows Notepad or Dreamweaver, for example), the files do have a BOM. I found that when I read them into LC variables, I have to strip the first two characters, otherwise my attempts to determine the code point of a specific character fail, because there are these two extra ones in front.
Yeah. Wikipedia mentioned that some apps will put in a BOM anyway, even though it screws up a lot of things (like the shebang in linux cgis, in particular.) They specifically warned about Windows apps. But anyway...
Now the same in detail:
I'll snip most of this in the interests of space, but it was very helpful in understanding what you need to do.
I know from the LC Dictionary that revBrowser does send three callback messages to the stack: browserClick, browserOut, and browserOver. In other words, revBrowser can, to a certain extent, inform the stack of what's going on in the Web page. I am hoping that someone has extended the capabilities of revBrowser, and that more interesting info can be sent to the stack by the Web page that revBrowser is displaying. Specifically, when my 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. That's my Question Number One.
As far as I know, there are no extensions to those three callbacks. It would be useful if there were. Your best bet is to put in a feature request in the QCC, but of course you probably don't want to wait.
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.
This should work, and is probably the best way right now.
So I put this script in the button's mouseUp handler: get revBrowserGet(gBrowserID, "selected") --"it" is now the text that the user selected in the Web page put uniEncode(it, "UTF8") into locSelectedText --now locSelectedText should be UTF-16 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." This is not a display or font problem--they are indeed question marks. We know that this type of remapping is done by older applications that are not Unicode-compliant. That is my Question Number Two: am I doing something wrong, or is the "selected" property of revBrowser incapable of holding a Unicode string?
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.
If that doesn't work: As I understand it (and remember, I've done little work with this,) the language parameter for uniEncode is the target language, not the originating language. The docs aren't too clear on that, but try:
put uniEncode(it,"Unicode") into locSelectedText And if that doesn't work, I can try to find out why. -- Jacqueline Landman Gay | jac...@hyperactivesw.com HyperActive Software | http://www.hyperactivesw.com _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode