WebViewer problem with unicode

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
snm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 253
Joined: Fri Dec 09, 2011 11:17 am

WebViewer problem with unicode

Post by snm » Sun Sep 02, 2012 7:24 pm

I need to display html files and html code from field. Problem starts when text is with unicode characters (accented letters).

When I open the html file in WebViewer using url "file:/.../filename.html" everything is OK, accented characters are displayed properly.
But if I put html code from the same file into the field, and want display it in WebViewer I can't get proper result.

Then I made test:
1. Loaded html file from URL - displayed correctly
2. set the unicodeText of fld "Field" to uniEncode (revBrowserGet (tID, "htmltext"), "UTF8") - got correct text (html code) in the field
3. displayed this code by revBrowserSet tID, uniDecode (fld "Field", "UTF8") - WebViewer shows "strange characters" not what it should display
4.displayed this code by revBrowserSet tID, uniDecode (the unicodeText of fld "Field", "UTF8") - I can see proper layout displayed, by any accented characters are visible as pairs of UTF8 replacements.

I have no idea how should be prepared "htmltext" property of WebViewer to display it correctly.

Any help welcome,
Marek

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: WebViewer problem with unicode

Post by shaosean » Sun Sep 02, 2012 7:30 pm

Try using a custom property as they can hold binary data without any conversion required, so this may help with the unicode issue as well (this is just a guess)

snm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 253
Joined: Fri Dec 09, 2011 11:17 am

Re: WebViewer problem with unicode

Post by snm » Sun Sep 02, 2012 9:17 pm

Hi shaosean, thnks for reply.

Could you explain what I should do - it seems I don't understand what I should do.

The only runaround which is working for me is to save html code to the file, and then open it to preview it in WebBrowser. I can't find any solution to preview this html code directly from the field (everything is working but accented unicode characters. It looks for me like "htmltext" property of WebViewer can be set only with ASCII characters while if you get this property you see it looks like utf8 converted original displayed text.

It's very strange that it is not working: get property --> set property with the same what you got from get property.

Marek

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: WebViewer problem with unicode

Post by shaosean » Mon Sep 03, 2012 1:25 am

Code: Select all

put url "binfile:/path/to/file.htm" into tHtmlData
set the htmlData of this stack to tHtmlData

Code: Select all

put the htmlData of stack into tHtmlData
revBrowserSet tBrowseID, "htmlText", tHtmlData

snm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 253
Joined: Fri Dec 09, 2011 11:17 am

Re: WebViewer problem with unicode

Post by snm » Mon Sep 03, 2012 5:35 pm

Sorry for late answer even if it's very urgent for me, but I was out of office and couldn't check it.

It's not working correct - there is not any difference if I set "htmltext" of VebWiewer from the field.
Any other idea how to solve it please?

Marek

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: WebViewer problem with unicode

Post by bn » Mon Sep 03, 2012 11:36 pm

Hi Marek,

I think the problem is a bug. See this thread
http://forums.runrev.com/viewtopic.php?f=19&t=8664
There is also a sample stack. Slavo tried every possible variation. If you pass the browser utf8 html it fails, this seems to be a Mac problem. If however you get the utf8 html from the browser and save it in a text file you can pass text file to the browser and it works. I tested it again and it works.

To get the unicodeText of the field into the browser you have to write it to a file and pass the filepath as a reference to the revBrowser

Code: Select all

global gBrowserID
on mouseUp
   put specialfolderpath(desktop) into tPath
   put "/russianTempIII.html" after tPath
   
   get the unicodeText of fld "field"
   put unidecode(it,"utf8") into url ("binfile:" & tPath)
   revBrowserSet gBrowserID, "URL",  tPath
end mouseUp
this works for me on MacOSX 10.6.8 LIvecode 5.5.1
Kind regards
Bernd

snm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 253
Joined: Fri Dec 09, 2011 11:17 am

Re: WebViewer problem with unicode

Post by snm » Tue Sep 04, 2012 8:59 am

Thanks a lot Bernd for reply and solution, but I have not problem to display html file even if I use just "file:" not "bin file:". The problem is if I want to display html code from field only. It's blocking my project as I'd like to preview changes made in this code dynamically.

Do you think that support can help me with that using one of my "Quick incident"?

Marek.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: WebViewer problem with unicode

Post by bn » Tue Sep 04, 2012 9:10 am

Hi Marek,

If I understand correctly what you want then the idea is to create a temporary file that displays the field in described way. Whenever you make changes to the field you could write the file out and display the file in the browser. It is a little slower than without the file but would be a workaround. You could trigger the update of the revbrowser either with an extra button or in the field on keyUp or on specific characters like space or somesuch.
About a "Quick incident" I don't know. Since you can describe the problem precisely it is worth a try. On the other hand it seems to be a problem with the revBrowser on MacOS, which is to my knowledge an external. To get that fixed might be more than a "Quick incident"
Kind regards
Bernd

snm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 253
Joined: Fri Dec 09, 2011 11:17 am

Re: WebViewer problem with unicode

Post by snm » Sat Sep 08, 2012 5:51 pm

Hi Bernd,

Sorry for late answer again, but I had very busy week in my office, and didn't even touch LiveCode and this forum.

My idea is to make simple text editor for check and edit html code before sending html eMail. I found runaround with saving edited code to the file and then open it in revBrowser, but it's much slower and not nice if you want to observe the changes dynamically. To trigger revBrowser refresh I'm using textChanged message.

You are right, revBrowser for Mac is extension, so there is no chance for me to edit it's code.
Is it working on Windows PC?

Best regards,
Marek

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: WebViewer problem with unicode

Post by bn » Sun Sep 09, 2012 11:08 pm

Hi Marek,
the problem was filed in the Quality Control Center = bugzilla as
Bug 9658
in 2011 and aknowledged. The workaround they suggest is the same as suggested here: write to a file and pass the local url to revBrowser.
I think they should fix it.
Kind regards
Bernd

snm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 253
Joined: Fri Dec 09, 2011 11:17 am

Re: WebViewer problem with unicode

Post by snm » Mon Sep 10, 2012 10:10 am

Hi Bernd,

I hope they will fix it. Thanks for info.

Best regards,
Marek

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: WebViewer problem with unicode

Post by bn » Mon Oct 29, 2012 4:31 pm

Hi Marek,

in LIvecode 5.5.3 the problem with passing html with utf8 to revBrowser on Mac is fixed. No more writing out to a file first.

Kind regards
Bernd

snm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 253
Joined: Fri Dec 09, 2011 11:17 am

Re: WebViewer problem with unicode

Post by snm » Mon Oct 29, 2012 4:44 pm

Hi Bernd,

Yes, I tried it already in rc and is working perfect. But thanks a lot you remembered about my problem.

Marek

Post Reply