I am having problems with processing certain special characters (ä ü ö) using Lotus Script. My guess is that there should be some Domino server setting which allows these characters to be retrieved as is when parsed through Lotus Script functions like Split, Trim etc.Here is the simple code example that is failing because of the special characters.
Dim session As New NotesSession
Dim doc As NotesDocument
Set doc=session.DocumentContext
Dim req As String
req=doc.Request_Content(0) 'this value is agenc@Hermann Bründl
Dim tmpv As Variant
tmpv = Split(req,"@")
dim usrnm as String
usrnm = tmpv(1) 'this should be Hermann Bründl - instead it is coming out as Hermann Br**ndl where the * indicates unknown character.
The view lookups based on the usrnm value are failing because the ü character is not properly interpreted.
Subject: Special Characters in Lotus Script
How exactly do you call this code? I would assume that you have created your own form tag, POST method, action pointing to an agent, right? LotusScript has no problems with umlaut characters in general, so that’s not the problem. How do you watch the value of usrnm? Do you print the output to a new website (if so, what character set is used), or is Br**ndl what you see in a stored document?
It would probably be a good idea to check with some HTTP header tools (e.g. LiveHTTPHeaders for Mozilla or ieHTTPHeaders for IE) what really is transfered from the browser to the server. You say, that the expected value in Request_Content is agenc@Hermann Bründl. That would be a little surprising to me, as Request_Content should contain field name and value pairs in a format like
FieldName1=FieldValue1&FieldName2=Fieldvalue2
If there is only one field, and its content is expected to be agenc@Hermann Bründl, your code should still retrieve the correct value.
The next thing I would check is the content type used when sending the request. Unfortunately there can be up to 3 (possibly conflicting) settings: One in the HTTP header of the page, one in a meta tag and the third in an enctype attribute of the form element. Should there be any conflicts, there are - to the best of my knowledge no hard and fast rules how a browser should deal with it (read: what content type to use for encoding).
Request_Content usually contains a URLEncoded string, so in general you should need to decode it into something usable, which can be tricky enough. Try to check the points I mentioned first and let’s see where it gets you.
Subject: RE: Special Characters in Lotus Script
Thanks for your help. You are right, the problem is not with Lotus Script but URL encoding.
This is how I call the AJAX based code:
var poststr = document.forms[0].inputField.value; // This is agenc
poststr += “@”+myName; // myName is Hermann Bründl
makePOSTRequest(‘postagentFBR?openagent’, poststr); // This is how I invoke the PostRequest
// Following is the key line in the makePOSTRequest function that is encoding the url
http_request.setRequestHeader(“Content-type”, “application/x-www-form-urlencoded”);
I commented out the above line but the error persists. Is that probably the default ‘Content-type’ setting?
I am looking further into URL decoding in Lotus Script, but are there other ‘Content-type’ parameters I can use?
Anyway, I think I am getting somewhere and hope you can help.
Subject: RE: Special Characters in Lotus Script
I give up.Instead of using req = doc.Request_Content(0), I used the Evaluate function as follows to get the req string value.
Const NotesMacro$ = |@URLDecode(“Platform”;Request_Content)| ’ same result with “Domino”, “Platform”, “UTF-8” or “ISO-8859-1”
tmpv = Evaluate(NotesMacro$, doc)
req = tmpv(0)
By the way, I am capturing the usrnm value as a tool-tip text on the same web page after the post agent returns it. The * character I was referring to is the little square that shows up in note pad when the character cannot be interpreted. When I use the Cstr(Uni()) to isolate the umlaut, I get 9500.
Subject: RE: Special Characters in Lotus Script
O.K., that explains the special content of your poststring.
I used to be very careful with evaluates in LS code, because I read some article a couple of years ago stating, that while the execution time of the @Formula was just as fast as any native formula, switching between the engines would take some considerable amount of time. However, my current testing results seem to confirm, that this is not much of an issue anymore. So I think, that this solution is pretty much O.K.
Did you try to encode (escape) the content of document.forms[0].inputField.value prior to adding it to your poststring?
Subject: RE: Special Characters in Lotus Script
Thank you very much Harkpabst,I am using the escape function in the form but the Lotus Script Evaluate function with @URLDecode is timing out and raising 500 error. So I had to fall back on the following old code, which in conjunction with the Replace function finally works. Hermann Bründl is back in business.
req=doc.Request_Content(0)
req = Replace(req,"%20"," ")
req = Replace(req,"%FC","ü")
Best regards,
Nagendra