mork에 해당되는 글 1건
/* 컨버팅 함수 만들었다.*/

int ConvertMorkStrToUnicode(const char* strIN, char *strOut, size_t outsize)
{
ASSERT(strIN);
int len = (int)strlen(strIN);

if (len > (int)outsize)
return -1;
int from=0, to=0;
char ch, cHigh, cLow;
while(len>from)
{
ch = strIN[from++];
switch(ch)
{
case 0x24: // '$': escape the next two hex bytes which encode a single octet
{
cHigh = strIN[from++];
cLow = strIN[from++];
cHigh = cHigh > 0x40 ? cHigh%0x37 : cHigh%0x30;
cLow  = cLow > 0x40 ? cLow%0x37 : cLow%0x30;
strOut[to++] = cHigh << 4 | cLow;
continue;
}
break;
case 0x5c: // '\\'
{
// CR,LF(#xD, #xA)
if (strIN[from] == 0x0d && strIN[from+1] == 0x0a) // escape line ending
{
from+=2;
continue;
}
ch = strIN[from++];
}
break;
case 0x29: // ')' End of literal
continue;
default:
break;
}
strOut[to++] = ch;
};
// terminate to null
strOut[to] = strOut[to+1] = 0;

return to;
}

이올린에 북마크하기(0) 이올린에 추천하기(0)
2010/02/06 17:47 2010/02/06 17:47

 태그 : 
이 글의 관련글(Trackback) 주소 :: http://www.sojins.net/tt/sojins/trackback/1093
Name
Password
Homepage
비밀글 (Secret)