2006年5月26日 星期五

dojo.io.bind 傳送 form 時中文 encoding 問題.

假設有個 FORM :

abc:


若是 abc 中輸入中文, 利用

var your_form = dojo.byId("your_form");

dojo.io.bind({
url: your_form.action,
formNode: your_form,
type: "text/javascript",
method: your_form.method,
load: function(type, value, evt) {
alert(value);
return ;
},
error: function(type, error) { alert("Error: " + type + "n" + error); }
});
你的 php 會得到 xxxxx; 的 ascii 編碼, 原因為在 io.js 中有會預設使用 encodeAscii 方式.
var enc = /utf/i.test(encoding||"") ? encodeURIComponent : dojo.string.encodeAscii;
所以要在加上 encoding 有 utf 的字樣即可得到以 UTF8 編碼的中文字傳至你的 PHP 中.. 所以 script 修改如下

var your_form = dojo.byId("your_form");

dojo.io.bind({
url: your_form.action,
formNode: your_form,
type: "text/javascript",
method: your_form.method,
encoding: 'UTF-8',
load: function(type, value, evt) {
alert(value);
return ;
},
error: function(type, error) { alert("Error: " + type + "n" + error); }
});

2006年5月21日 星期日

Introducing JSON

Introducing JSON: "SON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.

JSON is built on two structures:

* A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.
* An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.

These are universal data structures. Virtually all modern programming languages support them in one form or another. It makes sense that a data format that is interchangable with programming languages also be based on these structures."

2006年5月19日 星期五

FreeBSD 6.0 jail

最近把系統昇級到 FreeBSD 6.0 Release ..

最主要的原因就是因為 jail 已經整合進系統了,而且可於開機時自動啟動多個 jail ,
而不用自己寫 shell scripts.

未來, 所有 internet 的主機, 預設都會使用最少安裝, 然後使用 jail ,
再進入 jail 中安裝 apache/php/tomcat 等所需的 service .

對 host 來說, 一個 jail只是一個目錄, 只要用 tar 備份整個目錄即可.
要重建亦只要 untar 即可..

jail 相關的網站: http://memberwebs.com/nielsen/freebsd/jails/