Create Webpage with UTF8 content in WAM (RESOLVED)

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
soa
Posts: 320
Joined: Mon Dec 07, 2015 3:15 pm

Create Webpage with UTF8 content in WAM (RESOLVED)

Post by soa » Fri Oct 18, 2019 12:15 pm

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.

soa
Posts: 320
Joined: Mon Dec 07, 2015 3:15 pm

Re: Create Webpage with UTF8 content in WAM

Post by soa » Fri Oct 18, 2019 12:20 pm

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!

caseywhite
Posts: 108
Joined: Thu May 26, 2016 1:17 am

Re: Create Webpage with UTF8 content in WAM

Post by caseywhite » Sat Oct 19, 2019 4:09 am

You are missing this line to assign the name of the file to be shown to the user.

#http1.AttachmentFileName = 'yourfile.ext'

soa
Posts: 320
Joined: Mon Dec 07, 2015 3:15 pm

Re: Create Webpage with UTF8 content in WAM

Post by soa » Mon Oct 21, 2019 8:08 am

Thanks for the suggestion but I'm not trying to download a file I'm trying to display web content in the browser.

soa
Posts: 320
Joined: Mon Dec 07, 2015 3:15 pm

Re: Create Webpage with UTF8 content in WAM RESOLVED

Post by soa » Mon Oct 21, 2019 5:24 pm

With help of support I now know that this issue can be resolved by adding

#http1.Charset := 'utf-8'

Post Reply