|
|
| version 1.1, 2005/02/12 12:13:56 | version 1.2, 2005/04/01 15:35:48 |
|---|---|
| Line 5 | Line 5 |
| UINT codecnv_euctosjis(char *dst, UINT dcnt, const char *src, UINT scnt) { | UINT codecnv_euctosjis(char *dst, UINT dcnt, const char *src, UINT scnt) { |
| UINT orgdcnt; | UINT orgdcnt; |
| BOOL stringmode; | |
| UINT h; | UINT h; |
| UINT l; | UINT l; |
| (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; | |
| } | |
| orgdcnt = dcnt; | |
| stringmode = (((SINT)scnt) < 0); | |
| if (stringmode) { | |
| dcnt--; | |
| } | } |
| dcnt--; | while(scnt > 0) { |
| while(dcnt) { | scnt--; |
| h = (UINT8)*src++; | h = (UINT8)*src++; |
| if (h < 0x80) { // ascii | if ((h == 0) && (stringmode)) { |
| if (!h) { | break; |
| } | |
| else if (h < 0x80) { // ascii | |
| if (dcnt == 0) { | |
| break; | break; |
| } | } |
| dcnt--; | dcnt--; |
| Line 31 UINT codecnv_euctosjis(char *dst, UINT d | Line 38 UINT codecnv_euctosjis(char *dst, UINT d |
| } | } |
| } | } |
| else if (h == 0x8e) { | else if (h == 0x8e) { |
| if (scnt == 0) { | |
| break; | |
| } | |
| scnt--; | |
| l = (UINT8)*src++; | l = (UINT8)*src++; |
| if (!l) { | if (!l) { |
| break; | break; |
| } | } |
| if (dcnt == 0) { | |
| break; | |
| } | |
| dcnt--; | dcnt--; |
| if (dst) { | if (dst) { |
| dst[0] = (char)h; | dst[0] = (char)h; |
| Line 42 UINT codecnv_euctosjis(char *dst, UINT d | Line 56 UINT codecnv_euctosjis(char *dst, UINT d |
| } | } |
| } | } |
| else { | else { |
| if (scnt == 0) { | |
| break; | |
| } | |
| scnt--; | |
| l = (UINT8)*src++; | l = (UINT8)*src++; |
| if (!l) { | if (!l) { |
| break; | break; |
| Line 67 UINT codecnv_euctosjis(char *dst, UINT d | Line 85 UINT codecnv_euctosjis(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)); |
| } | } |