[ng-dhtml] [Dojo-checkins] r1623 - in trunk/src: . io

Martin Cooper martinc at apache.org
Mon Sep 26 19:00:14 CDT 2005


Can we make this 'utf8' instead of just 'utf'? I'm assuming that only 
UTF-8 is handled, and not UTF-16?

--
Martin Cooper


On Mon, 26 Sep 2005 dojo-checkins at dojotoolkit.org wrote:

> Author: david
> Date: Mon Sep 26 15:28:34 2005
> New Revision: 1623
>
> Modified:
>   trunk/src/io.js
>   trunk/src/io/BrowserIO.js
> Log:
> added support for defining the encoding to be used by bind calls. The thought is that you'd either set the "encoding" on the bind arguments or set djDebug.encoding. Possible values are "ascii" (default) or "utf". Hopefully this really fixes #112.
>
> Modified: trunk/src/io.js
> ==============================================================================
> --- trunk/src/io.js	(original)
> +++ trunk/src/io.js	Mon Sep 26 15:28:34 2005
> @@ -117,6 +117,15 @@
> 		if(!kwArgs["load"] && kwArgs["loaded"]){ kwArgs.load = kwArgs.loaded; }
> 		if(!kwArgs["changeUrl"] && kwArgs["changeURL"]) { kwArgs.changeUrl = kwArgs.changeURL; }
>
> +		// encoding fun!
> +		if(!kwArgs["encoding"]) {
> +			if(!dojo.lang.isUndefined(djConfig["bindEncoding"])) {
> +				kwArgs.encoding = djConfig.bindEncoding;
> +			} else {
> +				kwArgs.encoding = "";
> +			}
> +		}
> +
> 		var isFunction = dojo.lang.isFunction;
> 		for(var x=0; x<dojo.io.hdlrFuncNames.length; x++){
> 			var fn = dojo.io.hdlrFuncNames[x];
> @@ -178,12 +187,13 @@
> 	return request;
> }
>
> -dojo.io.argsFromMap = function(map){
> +dojo.io.argsFromMap = function(map, encoding){
> 	var control = new Object();
> 	var mapStr = "";
> +	var enc = /utf/i.test(encoding||"") ? encodeURIComponent : dojo.string.encodeAscii;
> 	for(var x in map){
> 		if(!control[x]){
> -			mapStr+= dojo.string.encodeAscii(x)+"="+dojo.string.encodeAscii(map[x])+"&";
> +			mapStr+= enc(x)+"="+enc(map[x])+"&";
> 		}
> 	}
>
>
> Modified: trunk/src/io/BrowserIO.js
> ==============================================================================
> --- trunk/src/io/BrowserIO.js	(original)
> +++ trunk/src/io/BrowserIO.js	Mon Sep 26 15:28:34 2005
> @@ -21,11 +21,11 @@
> }
>
> // TODO: Move to htmlUtils
> -dojo.io.encodeForm = function(formNode){
> +dojo.io.encodeForm = function(formNode, encoding){
> 	if((!formNode)||(!formNode.tagName)||(!formNode.tagName.toLowerCase() == "form")){
> 		dj_throw("Attempted to encode a non-form element.");
> 	}
> -	var enc = dojo.string.encodeAscii;
> +	var enc = /utf/i.test(encoding||"") ? encodeURIComponent : dojo.string.encodeAscii;
> 	var values = [];
>
> 	for(var i = 0; i < formNode.elements.length; i++) {
> @@ -377,7 +377,7 @@
> 			if((ta)&&(!kwArgs["url"])){ url = ta; }
> 			var tp = kwArgs.formNode.getAttribute("method");
> 			if((tp)&&(!kwArgs["method"])){ kwArgs.method = tp; }
> -			query += dojo.io.encodeForm(kwArgs.formNode);
> +			query += dojo.io.encodeForm(kwArgs.formNode, kwArgs.encoding);
> 		}
>
> 		if(!kwArgs["method"]) {
> @@ -385,7 +385,7 @@
> 		}
>
> 		if(kwArgs["content"]){
> -			query += dojo.io.argsFromMap(kwArgs.content);
> +			query += dojo.io.argsFromMap(kwArgs.content, kwArgs.encoding);
> 		}
>
> 		if(kwArgs["postContent"] && kwArgs.method.toLowerCase() == "post") {
> _______________________________________________
> Dojo-checkins mailing list
> Dojo-checkins at dojotoolkit.org
> http://dojotoolkit.org/mailman/listinfo/dojo-checkins
>



More information about the NG-DHTML mailing list