|
|
| version 1.1, 2005/02/12 12:13:56 | version 1.2, 2005/04/01 15:35:48 |
|---|---|
| Line 5 | Line 5 |
| UINT codecnv_sjistoeuc(char *dst, UINT dcnt, const char *src, UINT scnt) { | UINT codecnv_sjistoeuc(char *dst, UINT dcnt, const char *src, UINT scnt) { |
| UINT orgdcnt; | UINT orgdcnt; |
| BOOL stringmode; | |
| int s; | int s; |
| int c; | int c; |
| (void)scnt; // 判定してないのかよ | |
| if (src == NULL) { | if (src == NULL) { |
| return(0); | return(0); |
| } | } |
| orgdcnt = dcnt; | |
| if (dcnt == 0) { | if (dcnt == 0) { |
| dst = NULL; | dst = NULL; |
| dcnt = (UINT)-1; | |
| } | } |
| dcnt--; | orgdcnt = dcnt; |
| while(dcnt) { | stringmode = (((SINT)scnt) < 0); |
| if (stringmode) { | |
| dcnt--; | |
| } | |
| while(scnt > 0) { | |
| scnt--; | |
| s = (UINT8)*src++; | s = (UINT8)*src++; |
| if (s < 0x80) { // ascii | if ((s == '\0') && (stringmode)) { |
| if (!s) { | break; |
| } | |
| else if (s < 0x80) { // ascii | |
| if (dcnt == 0) { | |
| break; | break; |
| } | } |
| dcnt--; | dcnt--; |
| Line 31 UINT codecnv_sjistoeuc(char *dst, UINT d | Line 38 UINT codecnv_sjistoeuc(char *dst, UINT d |
| } | } |
| } | } |
| else if ((((s ^ 0x20) - 0xa1) & 0xff) < 0x2f) { | else if ((((s ^ 0x20) - 0xa1) & 0xff) < 0x2f) { |
| if (scnt == 0) { | |
| break; | |
| } | |
| scnt--; | |
| c = (UINT8)*src++; | c = (UINT8)*src++; |
| if (!c) { | if (c == '\0') { |
| break; | break; |
| } | } |
| if (dcnt < 2) { | if (dcnt < 2) { |
| Line 62 UINT codecnv_sjistoeuc(char *dst, UINT d | Line 73 UINT codecnv_sjistoeuc(char *dst, UINT d |
| } | } |
| } | } |
| } | } |
| if (dst) { | if (dst != NULL) { |
| dst[0] = '\0'; | if (stringmode) { |
| *dst = '\0'; | |
| } | |
| #if 1 // 一応互換の為に NULLつける | |
| else if (dcnt) { | |
| *dst = '\0'; | |
| } | |
| #endif | |
| } | } |
| return((UINT)(orgdcnt - dcnt)); | return((UINT)(orgdcnt - dcnt)); |
| } | } |