Revision: 2985
          http://vexi.svn.sourceforge.net/vexi/?rev=2985&view=rev
Author:   mkpg2
Date:     2008-07-21 18:51:35 +0000 (Mon, 21 Jul 2008)

Log Message:
-----------
Fix/workaround for the 'encoding chars with utf > 127 in xmlrpc' issue.

Modified Paths:
--------------
    trunk/core/org.ibex.js/src/org/ibex/js/XMLRPC.jpp

Modified: trunk/core/org.ibex.js/src/org/ibex/js/XMLRPC.jpp
===================================================================
--- trunk/core/org.ibex.js/src/org/ibex/js/XMLRPC.jpp   2008-07-21 16:46:11 UTC 
(rev 2984)
+++ trunk/core/org.ibex.js/src/org/ibex/js/XMLRPC.jpp   2008-07-21 18:51:35 UTC 
(rev 2985)
@@ -254,20 +254,21 @@
         } else if (o instanceof JSString) {
             sb.append("                <value><string>");
             String s = ((JSString)o).coerceToString();
-            if (s.indexOf('<') == -1 && s.indexOf('&') == -1) {
-                sb.append(s);
-            } else {
-                char[] cbuf = s.toCharArray();
-                int oldi = 0, i=0;
-                while(true) {
-                    while(i < cbuf.length && cbuf[i] != '<' && cbuf[i] != '&') 
i++;
-                    sb.append(cbuf, oldi, i - oldi);
-                    if (i >= cbuf.length) break;
-                    if (cbuf[i] == '<') sb.append("&lt;");
-                    else if (cbuf[i] == '&') sb.append("&amp;");
-                    i = oldi = i + 1;
-                    if (i >= cbuf.length) break;
-                }
+            char[] cbuf = s.toCharArray();
+            int oldi = 0, i=0;
+            // REMARK - encoding chars > 127 using number entities
+            // &#xxx;, this works but is it necessary?! It should be
+            // possible to utf8 encode shouldn't it? Or do we then
+            // need a CDATA block ??? 
+            while(true) {
+               while(i < cbuf.length && cbuf[i] != '<' && cbuf[i] != '&' && 
cbuf[i]<=127 ) i++;
+               sb.append(cbuf, oldi, i - oldi);
+               if (i >= cbuf.length) break;
+               if (cbuf[i] == '<') sb.append("&lt;");
+               else if (cbuf[i] == '&') sb.append("&amp;");
+               else if (cbuf[i] > 127) sb.append("&#"+(int)cbuf[i]+";");
+               i = oldi = i + 1;
+               if (i >= cbuf.length) break;
             }
             sb.append("</string></value>\n");
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to