How to transfer LMBCS string into UTF8 format & Print it?

Hi,

I’d like to print a SOAP response message to a Web Service caller ,

I did print the <?xml version="1.0" encoding="utf-8" ?> in SOAP response message , but I got a trouble when I print a Traditional Chinese char , the caller will get ??? code .

I cannot transfer the response string to UTF-8 format successfully ,

Please help , thanks .

Subject: Use @URLEncode() and Evaluate

Use Lotusscript’s Evaluate() function to run @URLEncode(“UTF-8”, “yourTextToBeEncoded”)…

If the text you need to encode is more than 64k, you need to store the text in a in-memory document and reference the document’s item via the Evaluate function instead, as you cannot use more than 64k of literal string text in @formulas.

Thomas - IBM

Subject: RE: Use @URLEncode() and Evaluate

Hi, Thomas :

I tried your way , but get a string that had transfer all special char (like “<” ,“>”) and Traditional Chinese char to some “%xx%yy%zz” code , where “%xx” indicate to a ascii code for the char.

But ,this seems not an acceptable format for a Soap Message , the caller cannot parse the message .

Roger

Subject: How to transfer LMBCS string into UTF8 format & Print it ?

If the first line that you print is like:Content-Type: text/xml; charset=utf-8

then Domino uses this to replace its default Content-Type header, and also parses it and converts everything else that you print to the specified charset. Strange but useful.

By the way, a String in LotusScript is Unicode, not LMBCS.

Subject: RE: How to transfer LMBCS string into UTF8 format & Print it ?

Hi, Rod :

Thanks for your advices , it helps so much.

When I Create a notesstream, and set it as a xmldomparser output , the original charset is unicode, but the charset of the notesstream will be changed to x-lmbcs automatically after I execute xmldomparser.serialize, is it normally or I miss any setting ?

Subject: RE: How to transfer LMBCS string into UTF8 format & Print it ?

Hi Roger

I got the same pb :

  • I have a NotesStream in UTF-8

  • after using NotesXslTransformer, my NotesStream is still in UTF-8.

  • but after using NotesDOMParses, my NotesStream changes into X-LMBCS.

=> I used a workaround :

Set tmpdoc = db.createdocument

tmpdoc.xml = stream.ReadText

v = Evaluate( "@URLDecode( ““UTF-8"”; xml )”, tmpdoc )

Set tmpStream = session.CreateStream

Call tmpStream.WriteText( v(0) )

'PARSE

Set parsedStream = session.CreateStream

Set domParser = session.CreateDOMParser( tmpStream, parsedStream )

'Get Nodes with dom parsed

Call domParser.Parse

Set nodeDoc = …

'GET result stream

Call domParser.Serialize

Hope this helps