문자메세지 같은거 보낼때 보면 80바이트로 제한을 둡니다. 

(한글은 2바이트기 때문에 euc-kr로 설정되어 있습니다.)

댓글 처음 단 녀석이 물어보길래 만들어줬는데

은근히 찾는 사람이 있을거 같아서 올려봅니다.

trace( restrictionStringBytes( "abcdedfghijklmnopq", 10 ) );
trace( restrictionStringBytes( "ab가나다라마바사", 10 ) );
trace( restrictionStringBytes( "야꼬는 고급인력!", 10 ) );
trace( restrictionStringBytes( "1가2나3다4라", 10 ) );

// abcdedfghi
// ab가나다라
// 야꼬는 고?
// 1가2나3다4

function restrictionStringBytes( str: String, bytes: int ): String
{
     var byte: ByteArray = new ByteArray();
     byte.writeMultiByte( str, "euc-kr" );
     byte.position = 0;
    
     var resctrictedByte: ByteArray = new ByteArray();
     byte.readBytes( resctrictedByte, 0, bytes );
     resctrictedByte.position = 0;
    
     var rtn: String = resctrictedByte.readMultiByte( resctrictedByte.length, "euc-kr" );
     return rtn;
}

p.s) 근수야 찾던게 이거 맞지?

'ActionScript 3.0 > 팁 & 노하우' 카테고리의 다른 글

[AS3] Flash CS4 로컬 도움말 위치  (11) 2008.11.04
[AS3] 네이밍과 코드 스타일  (31) 2008.10.26
[AS3] 영역 구하기.  (8) 2008.09.24
[AS3] 최적화 코드  (9) 2008.09.08
[AS3] 몇 초 후에 메소드 실행하기  (23) 2008.09.01

+ Recent posts