/* 컨버팅 함수 만들었다.*/

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)
Mork Sturcture
source : https://developer.mozilla.org/en/Mork_Structure
FireFox2에서 사용하는 history.dat 의 name(url title) 인코딩 참조

Literals

A Mork literal is a binary octet sequence encoded as plain text. Every byte becomes literally the next byte of the value, unless certain bytes are seen which have metacharacter status. (Why is there more than one metachar? Because it might shrink markup. Complexity here is worth some compression.)

  • ) - close paren - end of literal
  • $ - dollar - escape the next two hex bytes which encode a single octet
  • \ - backslash - if the next byte is either #xA or #xD, omit linebreak from literal; otherwise escape next byte. For example, \ removes metachar status from an immediately following \, $, or ).

The first metachar is close paren. A literal always appears at the tail end of a cell which is always terminated by a close paren ), so in practice every literal is terminated by ). The only way to get ) inside a literal is by escaping the ) byte one way or other.

The second metachar is dollar $, which allows you to encode any octet as two digits of hex. Some writers might encode all non-ascii octets this way, and the year 2000 version of Mozilla did this, but it's not required. You are never required to use $ to escape bytes when writing, but readers must escape hex following $ when $ itself is not escaped, say using \. (Why did I choose $ for this metachar? Because I thought URLs might be common Mork content, and I wanted to use a byte that might appear less often in URLs.)

The third metachar is backslash \, which was added to allow escaping metachars using C like syntax, and to allow line continuation in a C like manner so very long lines need not be generated unless a writer insists.

(If I was going to extend Mork for base 64, I'd probably extend the meaning of the $ metachar to understand a following non-hex byte was the start of a base 64 sequence. For example, ${ABC} might mean ABC was base 64 content. I've seen folks online bitch about Mozilla's verbose encoding of unicode under Mork using $ to encode every null byte. Why didn't you speak up during the year I discussed it online? In five years, why did no one tweak Mork so version 1.5 would do better? Why not just write unicode as raw binary, since Mork supports that? Why does Mork suck because no one spends an hour making changes? Whatever.)


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

 태그 : 
이 글의 관련글(Trackback) 주소 :: http://www.sojins.net/tt/sojins/trackback/1092
sojins| 2010/02/06 16:33 | PERMALINK | EDIT/DEL | REPLY
// Hex Char to int ;-)
char cHign = 'D', cLow='0', cHex=0;
cHigh = cHigh > 0x40 ? cHigh%0x37 : cHigh%0x30;
cLow = cLow > 0x40 ? cLow%0x37 : cLow%0x30;
cHex = cHigh << 4 | cLow;
Name
Password
Homepage
비밀글 (Secret)
http://www.securitytechnet.com/std-algorithm/hash.html


이올린에 북마크하기(0) 이올린에 추천하기(0)
2010/01/12 14:14 2010/01/12 14:14

이 글의 관련글(Trackback) 주소 :: http://www.sojins.net/tt/sojins/trackback/1091
Name
Password
Homepage
비밀글 (Secret)
http://kangcom.com/sub/view.asp?topid=1&sku=2009F0195412

책 구매

글쓰기 안되서 다시 썼다 -_ㅜ
이올린에 북마크하기(0) 이올린에 추천하기(0)
2010/01/12 11:26 2010/01/12 11:26

이 글의 관련글(Trackback) 주소 :: http://www.sojins.net/tt/sojins/trackback/1090
sojins| 2010/01/25 14:37 | PERMALINK | EDIT/DEL | REPLY
책 도착.
Name
Password
Homepage
비밀글 (Secret)
굿바이, 2009
올해 우여곡절 참 많았다.

내년엔
올해를 액땜삼아

쭉쭉~ 뻗어나갔으면.

모두모두 새해 복 많이~
대박나시옵소서~

(- -)(_ _) 꾸벅
이올린에 북마크하기(0) 이올린에 추천하기(0)
2009/12/31 14:55 2009/12/31 14:55

이 글의 관련글(Trackback) 주소 :: http://www.sojins.net/tt/sojins/trackback/1089
earman| 2010/01/02 02:16 | PERMALINK | EDIT/DEL | REPLY
수고 많았소.
내년에도 잘…
Name
Password
Homepage
비밀글 (Secret)