js unicode转中文

var zh = {
	common : {
		edit_confirm : "\u662F\u5426\u5728\u6B64textarea\u6A19\u7C64\u5167\u4F7F\u7528\u300C\u6240\u898B\u5373\u6240\u5F97\u300D\u6A21\u5F0F\uFF1F",
		apply : "\u61C9\u7528",
		insert : "\u63D2\u5165",
		update : "\u66F4\u65B0",
		cancel : "\u53D6\u6D88",
		close : "\u95DC\u9589",
		browse : "\u700F\u89BD",
		class_name : "\u6A23\u5F0F",
		not_set : "--\u672A\u8A2D\u7F6E--",
		clipboard_msg : "\u8907\u88FD\u3001\u526A\u4E0B\u3001\u8CBC\u4E0A\u529F\u80FD\u5728Mozilla\u548CFirefox\u4E2D\u4E0D\u80FD\u4F7F\u7528\u3002 \n\u662F\u5426\u9700\u8981\u77AD\u89E3\u66F4\u591A\u6709\u95DC\u6B64\u554F\u984C\u7684\u4FE1\u606F\uFF1F",
		clipboard_no_support : "\u9084\u4E0D\u652F\u6301\u60A8\u7684\u700F\u89BD\u5668\uFF0C\u8ACB\u4F7F\u7528\u9375\u76E4\u5FEB\u6377\u65B9\u5F0F",
		popup_blocked : "\u62B1\u6B49\uFF01\u5F48\u51FA\u7A97\u53E3\u5DF2\u88AB\u963B\u6B62\uFF0C\u8ACB\u8ABF\u6574\u700F\u89BD\u5668\u8A2D\u7F6E\uFF0C\u5141\u8A31\u6B64\u7DB2\u7AD9\u53EF\u5F48\u51FA\u65B0\u7A97\u53E3\uFF0C\u4EE5\u4FBF\u4F7F\u7528\u6B64\u5DE5\u5177",
		invalid_data : "\u932F\u8AA4:\u7121\u6548\u8F38\u5165\u503C\uFF0C\u5DF2\u6A19\u8A18\u70BA\u7D05\u8272\u3002",
		more_colors : "\u66F4\u591A\u984F\u8272"
	},
	contextmenu : {
		align : "\u5C0D\u9F4A\u65B9\u5F0F",
		left : "\u9760\u5DE6\u5C0D\u9F4A",
		center : "\u7F6E\u4E2D\u5C0D\u9F4A",
		right : "\u9760\u53F3\u5C0D\u9F4A",
		full : "\u5DE6\u53F3\u5C0D\u9F4A"
	},
	insertdatetime : {
		date_fmt : "%Y-%m-%d",
		time_fmt : "%H:%M:%S",
		insertdate_desc : "\u63D2\u5165\u4ECA\u5929\u65E5\u671F",
		inserttime_desc : "\u63D2\u5165\u73FE\u5728\u6642\u9593",
		months_long : "\u4E00\u6708,\u4E8C\u6708,\u4E09\u6708,\u56DB\u6708,\u4E94\u6708,\u516D\u6708,\u4E03\u6708,\u516B\u6708,\u4E5D\u6708,\u5341\u6708,\u5341\u4E00\u6708,\u5341\u4E8C\u6708",
		months_short : "1,2,3,4,5,6,7,8,9,10,11,12",
		day_long : "\u661F\u671F\u65E5,\u661F\u671F\u4E00,\u661F\u671F\u4E8C,\u661F\u671F\u4E09,\u661F\u671F\u56DB,\u661F\u671F\u4E94,\u661F\u671F\u516D,\u661F\u671F\u65E5",
		day_short : "\u9031\u65E5,\u9031\u4E00,\u9031\u4E8C,\u9031\u4E09,\u9031\u56DB,\u9031\u4E94,\u9031\u516D,\u9031\u65E5"
	},
	print : {
		print_desc : "\u6253\u5370"
	},
	preview : {
		preview_desc : "\u9810\u89BD"
	},
	directionality : {
		ltr_desc : "\u6587\u5B57\u5F9E\u5DE6\u5230\u53F3",
		rtl_desc : "\u6587\u5B57\u5F9E\u53F3\u5230\u5DE6"
	},
	layer : {
		insertlayer_desc : "\u63D2\u5165\u5C64",
		forward_desc : "\u4E0A\u79FB\u4E00\u5C64",
		backward_desc : "\u4E0B\u79FB\u4E00\u5C64",
		absolute_desc : "\u958B\u95DC\u7D55\u5C0D\u4F4D\u7F6E",
		content : "\u65B0\u589E\u5C64..."
	},
	save : {
		save_desc : "\u4FDD\u5B58",
		cancel_desc : "\u53D6\u6D88\u6240\u6709\u66F4\u6539"
	},
	nonbreaking : {
		nonbreaking_desc : "\u63D2\u5165\u4E0D\u65B7\u884C\u7A7A\u767D"
	},
	iespell : {
		iespell_desc : "\u62FC\u5B57\u6AA2\u67E5",
		download : "\u672A\u6AA2\u6E2C\u5230ieSpell\u7684\u5B58\u5728\u3002\u662F\u5426\u73FE\u5728\u7ACB\u5373\u5B89\u88DD\uFF1F"
	},
	advhr : {
		advhr_desc : "\u6C34\u5E73\u7DDA"
	},
	emotions : {
		emotions_desc : "\u5716\u793A"
	},
	searchreplace : {
		search_desc : "\u67E5\u627E",
		replace_desc : "\u67E5\u627E/\u66FF\u63DB"
	},
	advimage : {
		image_desc : "\u63D2\u5165/\u7DE8\u8F2F\u5716\u7247"
	},
	advlink : {
		link_desc : "\u63D2\u5165/\u7DE8\u8F2F\u9023\u7D50"
	},
	xhtmlxtras : {
		cite_desc : "\u5F15\u6587",
		abbr_desc : "\u7E2E\u5BEB",
		acronym_desc : "\u9996\u5B57\u7E2E\u5BEB",
		del_desc : "\u522A\u9664",
		ins_desc : "\u63D2\u5165",
		attribs_desc : "\u63D2\u5165/\u7DE8\u8F2F\u5C6C\u6027",
		attribs_delta_width : "40",
		attribs_delta_height : "60"
	},
	style : {
		desc : "\u7DE8\u8F2FCSS\u6A23\u5F0F\u8868\u55AE"
	},
	paste : {
		paste_text_desc : "\u7D14\u6587\u672C\u7C98\u8CBC",
		paste_word_desc : "\u5F9EWord\u7C98\u8CBC",
		selectall_desc : "\u5168\u9078"
	},
	paste_dlg : {
		text_title : "\u5728\u9375\u76E4\u4E0A\u540C\u6642\u6309\u4E0BCTRL\u548CV\u9375\uFF0C\u4EE5\u8CBC\u4E0A\u6587\u5B57\u5230\u6B64\u7A97\u53E3\u3002",
		text_linebreaks : "\u4FDD\u7559\u63DB\u884C\u7B26",
		word_title : "\u5728\u9375\u76E4\u4E0A\u540C\u6642\u6309\u4E0BCTRL\u548CV\u9375\uFF0C\u4EE5\u8CBC\u4E0A\u6587\u5B57\u5230\u6B64\u7A97\u53E3\u3002"
	},
	table : {
		desc : "\u63D2\u5165\u65B0\u8868\u683C",
		row_before_desc : "\u63D2\u5165\u4E0A\u65B9\u884C",
		row_after_desc : "\u63D2\u5165\u4E0B\u65B9\u884C",
		delete_row_desc : "\u522A\u9664\u6240\u5728\u884C",
		col_before_desc : "\u63D2\u5165\u5DE6\u65B9\u5217",
		col_after_desc : "\u63D2\u5165\u53F3\u65B9\u5217",
		delete_col_desc : "\u522A\u9664\u6240\u5728\u5217",
		split_cells_desc : "\u5206\u5272\u55AE\u5143\u683C",
		merge_cells_desc : "\u5408\u4F75\u55AE\u5143\u683C",
		row_desc : "\u884C\u5C6C\u6027",
		cell_desc : "\u55AE\u5143\u683C\u5C6C\u6027",
		props_desc : "\u8868\u683C\u5C6C\u6027",
		paste_row_before_desc : "\u8CBC\u5728\u4E0A\u65B9\u884C",
		paste_row_after_desc : "\u8CBC\u5728\u4E0B\u65B9\u884C",
		cut_row_desc : "\u526A\u4E0B\u9078\u64C7\u884C",
		copy_row_desc : "\u8907\u88FD\u9078\u64C7\u884C",
		del : "\u522A\u9664\u8868\u683C",
		row : "\u884C",
		col : "\u5217",
		cell : "\u55AE\u5143\u683C",
		cellprops_delta_width : "10",
		cellprops_delta_height : "10",
		table_delta_width : "40",
		table_delta_height : "60",
		merge_cells_delta_width : "40",
		merge_cells_delta_height : "40"
	},
	autosave : {
		unload_msg : "\u5982\u679C\u96E2\u958B\u6B64\u9801\u9762\u5C07\u5C0E\u81F4\u6240\u505A\u7684\u66F4\u6539\u5168\u90E8\u4E1F\u5931\u3002"
	},
	fullscreen : {
		desc : "\u5168\u5C4F\u5E55\u6A21\u5F0F"
	},
	media : {
		desc : "\u63D2\u5165/\u7DE8\u8F2F\u5D4C\u5165\u5A92\u9AD4",
		edit : "\u7DE8\u8F2F\u5D4C\u5165\u5A92\u9AD4"
	},
	fullpage : {
		desc : "\u5C6C\u6027"
	},
	template : {
		desc : "\u63D2\u5165\u9810\u5B9A\u7684\u7BC4\u672C\u5167\u5BB9"
	},
	visualchars : {
		desc : "\u986F\u793A\u63A7\u5236\u7B26\u865F"
	},
	spellchecker : {
		desc : "\u62FC\u5BEB\u6AA2\u67E5",
		menu : "\u62FC\u5BEB\u6AA2\u67E5\u8A2D\u7F6E",
		ignore_word : "\u7565\u904E",
		ignore_words : "\u5168\u90E8\u7565\u904E",
		langs : "\u8A9E\u8A00",
		wait : "\u8ACB\u7A0D\u5019...",
		sug : "\u63A8\u85A6\u5B57\u8A5E",
		no_sug : "\u7121\u62FC\u5BEB\u63A8\u85A6",
		no_mpell : "\u672A\u767C\u73FE\u62FC\u5BEB\u932F\u8AA4"
	},
	pagebreak : {
		desc : "\u63D2\u5165\u5206\u9801\u7B26\u865F"
	}
}
//多套一层
var d = {
	"zh" : zh
};

function encode(obj) {
	for (var i in obj) {
		if (typeof obj[i] == 'string') {
			obj[i] = escape(obj[i]);
		} else if (typeof obj[i] == 'object') {
			obj[i] = encode(obj[i]);
		}
	}
	return obj;
}

//添加显示容器
function addBox() {
	document.body.innerHTML = "";
	document.body.innerHTML = '<textarea id="sss" cols="200" rows="30"></textarea>';
}

//汉字转unicode
function f1(obj) {
	addBox();
	var s = encode(obj);
	s = JSON.stringify(s).replace(/%u/g, "\\u");
	document.querySelector('#sss').value = unescape(s);
	//验证数据
	s = JSON.parse(s);
	console.log(s);
}

//unicode转汉字
function f2(obj) {
	addBox();
	var s = JSON.stringify(obj);
	document.querySelector('#sss').value = s;
}

f1(d);

 

你可能感兴趣的:(js unicode转中文)