|
From: creedon <icr...@us...> - 2005-06-14 03:11:14
|
Update of /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/xml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21818 Modified Files: entityEncode Log Message: comment test code bundle Index: entityEncode =================================================================== RCS file: /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/xml/entityEncode,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** entityEncode 26 Mar 2005 19:44:15 -0000 1.1.1.1 --- entityEncode 14 Jun 2005 03:11:04 -0000 1.2 *************** *** 1,3 **** FrontierVcsFile:1:scpt:system.verbs.builtins.xml.entityEncode ! on entityEncode (s, flAlphaEntities = false) { ÇChanges Ç10/22/99; 2:14:49 PM by DW ÇIn some circumstances, sending non-escaped eight-bit ASCII characters causes XML parsers to reject the XML, esp if no character encoding is specified. This can be a problem when you're accepting text that could have been entered on a Mac or a PC or whatever, and you don't know what the characters mean, so you don't know how to declare the encoding. In those cases, we still want to be able to send the text, so we "entity-encode" the text, as specified in the XML spec on the W3C site. ÇThis new verb processes the input string, and returns a string with all high-bit characters replaced with the equivalent encoding. Çhttp://www.w3.org/TR/1998/REC-xml-19980210#wf-Legalchar Ç11/14/2000; 5:55:38 PM by DW ÇEncode alpha entitites. See the comment at the head of xml.entityEncode. local (i = 1, num); while i <= sizeof (s) { num = number (s [i]); if num >= 128 { s = string.delete (s, i, 1); s = string.insert ("&#" + num + ";", s, i); i = i + 5}; i++}; bundle { //encode alpha entities if flAlphaEntities { s = string.replaceall (s, "<", "<"); s = string.replaceall (s, ">", ">"); s = string.replaceall (s, "&", "&"); s = string.replaceall (s, "\"", """)}}; return (s)}; bundle { //test code dialog.alert (entityEncode ("Olejováø \"skvrna\" na Labi zøejmì do Nìmecka nedoplujeøíjna 1999 13:49", true))} \ No newline at end of file --- 1,3 ---- FrontierVcsFile:1:scpt:system.verbs.builtins.xml.entityEncode ! on entityEncode (s, flAlphaEntities = false) { ÇChanges Ç10/22/99; 2:14:49 PM by DW ÇIn some circumstances, sending non-escaped eight-bit ASCII characters causes XML parsers to reject the XML, esp if no character encoding is specified. This can be a problem when you're accepting text that could have been entered on a Mac or a PC or whatever, and you don't know what the characters mean, so you don't know how to declare the encoding. In those cases, we still want to be able to send the text, so we "entity-encode" the text, as specified in the XML spec on the W3C site. ÇThis new verb processes the input string, and returns a string with all high-bit characters replaced with the equivalent encoding. Çhttp://www.w3.org/TR/1998/REC-xml-19980210#wf-Legalchar Ç11/14/2000; 5:55:38 PM by DW ÇEncode alpha entitites. See the comment at the head of xml.entityEncode. local (i = 1, num); while i <= sizeof (s) { num = number (s [i]); if num >= 128 { s = string.delete (s, i, 1); s = string.insert ("&#" + num + ";", s, i); i = i + 5}; i++}; bundle { //encode alpha entities if flAlphaEntities { s = string.replaceall (s, "<", "<"); s = string.replaceall (s, ">", ">"); s = string.replaceall (s, "&", "&"); s = string.replaceall (s, "\"", """)}}; return (s)}; Çbundle //test code Çdialog.alert (entityEncode ("Olejováø \"skvrna\" na Labi zøejmì do Nìmecka nedoplujeøíjna 1999 13:49", true)) \ No newline at end of file |