자바 스크립트로 unicode 인코딩 과 디코딩은 다음과 같이 하면 된다.

function decodeUnicode(unicodeString) {
	var r = /\\u([\d\w]{4})/gi;
	unicodeString = unicodeString.replace(r, function (match, grp) {
	    return String.fromCharCode(parseInt(grp, 16)); } );
	return unescape(unicodeString);
}


function encodeUnicode(convertString) {
	var unicodeString = '';
	for (var i=0; i < convertString.length; i++) {
		var theUnicode = convertString.charCodeAt(i).toString(16).toUpperCase();

		while (theUnicode.length < 4) {
			theUnicode = '0' + theUnicode;
		}

		theUnicode = '\\u' + theUnicode;
		unicodeString += theUnicode;
	}

	return unicodeString;
}

encodeUnicode("김초보");
decodeUnicode("\uAE40\uCD08\uBCF4");

결과는

\uAE40\uCD08\uBCF4
김초보

이다.

특정 필드가 업데이트 될 때 트리거를 작동하게 해야 할 때가 있다.

그럴 때는 다음과 같이 트리거를 생성하면 된다.

CREATE  TRIGGER  tg_my_trigger AFTER UPDATE ON tbl_my_table
 FOR EACH ROW
BEGIN
if NEW.column1 <> OLD.column1
begin 
--작성
end
END

디스크가 부족할 시 현재 어느 폴더에서 디스크 용량을 차지하는지 확인해야 할 때가 있다. 그럴때 다음 명령어로 확인해 보자.

sudo du -ckx | sort -n

+ Recent posts