Encoding encKor = Encoding.GetEncoding("ks_c_5601-1987");
Console.WriteLine(encKor.GetByteCount(inString));
'byte'에 해당되는 글 3건
- 2011.09.20 byte 수 체크
- 2009.09.17 byte check
- 2009.09.17 Byte Check
'------------------------------------------------------------------------------
' Description : byte(바이트) 글자 체크
'------------------------------------------------------------------------------
function fn_ByteLen(str)
tlen=0
tt=len(str)
k=1
for i=1 to tt
if asc(mid(str,k,1)) < 0 then
tlen=tlen+2
else
tlen=tlen+1
end if
k=k+1
next
fn_ByteLen=tlen
end function
' Description : byte(바이트) 글자 체크
'------------------------------------------------------------------------------
function fn_ByteLen(str)
tlen=0
tt=len(str)
k=1
for i=1 to tt
if asc(mid(str,k,1)) < 0 then
tlen=tlen+2
else
tlen=tlen+1
end if
k=k+1
next
fn_ByteLen=tlen
end function
function calculateBytes( szValue)
{
var tcount = 0;
var tmpStr = new String(szValue);
var temp = tmpStr.length;
var onechar;
for ( k=0; k<temp; k++ )
{
onechar = tmpStr.charAt(k);
if (escape(onechar).length > 4)
{
tcount += 2;
}
else
{
tcount += 1;
}
}
return tcount;
}
[출처] 자바스크립트로 정확한 바이트 수 체크하기.|작성자 협객