This Blog has moved to http://www.falsepositives.com/

False Positives Adventures in Technology, SciFi and Culture from Toronto

Tuesday, February 08, 2005

XML encoding a string in JavaScript

Via SearchDomino and Ronald Pijper:XML encoding a string: XML strings must be encoded to conform to standards. Unfortunately, in Domino there are no XML encoding functions like @URLEncode.

The code is a JavaScriptLotusScript version of this function. It encodes the five specific entities into their XML encoded ones. For all characters outside of the basic ACII, set it to encode these with the character code.

Update:Rich Schwartz correctly points out that the code was LotusScript. That's what I get for doing a quick blog post (before dashing out to dinner) with out trying the code myself. Interestingly the SearhDomino guys changed their post, after, to reflect that it was LotusScript. My bad.


Please Note that this Blog (False Positives) has moved to http://www.falsepositives.com/

1 Comments:

  • I think you meant "LotusScript" rather than JavaScript in the title of this post.

    Also, I think you need to put a CDATA block around your code sample. Viewed in a browser, the case statement looks wrong because the browser is translating the entity values into characters, which makes it look like the statements aren't really doing anything.

    Lastly, I think it's probably necessary to use the Uni() function rather than the Asc() in the output stage, because XML entity values should be Unicode not ASCII. It's probably better to use Uni() in the if test, too, although whether that's really necessary depends on what your input source is.

    -rich schwartz

    By Anonymous Anonymous, at 11:29 PM  

Post a Comment

Links to this post:

Create a Link

<< Home