Page 1 of 1

Create Webpage with UTF8 content in WAM (RESOLVED)

Posted: Fri Oct 18, 2019 12:15 pm
by soa
I have a WAM with a Response(#http1) and I'm build a webpage containing UTF8 string (*NVARCHAR)

I'm building the page

#workutf8 := '<html><head>'
...
#workutf8 += #ONXTX8
...
#workutf8 += '</body><html>'

#MyFile.CreateTemporaryFile
#MyFile.WriteAllText Text(#workutf8)

#http1.ContentFile := #MyFile
#http1.ContentType := 'text/html'
#http1.RemoveFile := true

This displays a page of junk (little square boxes lots of letters wth accents etcetera).

If I remove the content type the page is downloaded but readable.

Any ideas about what I'm doing wrong.

I'm getting utf-8 from an external source ad I need to to display it without losing anything which I can't do with WEBEVENT.

If I build the file as above on the iseries as '\home\myfile.html' it displays beautifully in the browser.

Re: Create Webpage with UTF8 content in WAM

Posted: Fri Oct 18, 2019 12:20 pm
by soa
Addendum to above. If I remove the ContentType lansa creates a file call LANSAWEB (no extension). If I locate the downloaded file in on my PC and add an extension of html and then double click it it opens and displays exactly what I want to see. So I'm very close!

Re: Create Webpage with UTF8 content in WAM

Posted: Sat Oct 19, 2019 4:09 am
by caseywhite
You are missing this line to assign the name of the file to be shown to the user.

#http1.AttachmentFileName = 'yourfile.ext'

Re: Create Webpage with UTF8 content in WAM

Posted: Mon Oct 21, 2019 8:08 am
by soa
Thanks for the suggestion but I'm not trying to download a file I'm trying to display web content in the browser.

Re: Create Webpage with UTF8 content in WAM RESOLVED

Posted: Mon Oct 21, 2019 5:24 pm
by soa
With help of support I now know that this issue can be resolved by adding

#http1.Charset := 'utf-8'