| 626 |
} |
} |
| 627 |
|
|
| 628 |
if(text) { |
if(text) { |
| 629 |
iconv_close(codeSet); |
delete text; |
| 630 |
return text; |
text = NULL; |
| 631 |
} |
} |
| 632 |
|
|
| 633 |
text = new wxString(); |
text = new wxString(); |
| 678 |
char fullPath[MAX_BUF_SIZE]; |
char fullPath[MAX_BUF_SIZE]; |
| 679 |
FILE* fp; |
FILE* fp; |
| 680 |
iconv_t codeSet; |
iconv_t codeSet; |
| 681 |
char inbuf[MAX_WIKI_TEXT_SIZE]; |
char* inbuf; |
| 682 |
char outbuf[MAX_WIKI_TEXT_SIZE]; |
char* outbuf; |
| 683 |
const char* inbufPtr; |
const char* inbufPtr; |
| 684 |
char* outbufPtr; |
char* outbufPtr; |
| 685 |
int inbufSize; |
int inbufSize; |
| 686 |
int outbufSize; |
int outbufSize; |
| 687 |
|
|
| 688 |
|
inbuf = (char*)malloc(MAX_WIKI_TEXT_SIZE); |
| 689 |
|
outbuf = (char*)malloc(MAX_WIKI_TEXT_SIZE); |
| 690 |
|
if(inbuf == NULL || outbuf == NULL) { |
| 691 |
|
MN_FATAL_ERROR(wxT("It's too big data. Max size is 5MB.")); |
| 692 |
|
} |
| 693 |
|
|
| 694 |
codeSet = iconv_open(CODE_SET_EUC_JP, CODE_SET_SYSTEM); |
codeSet = iconv_open(CODE_SET_EUC_JP, CODE_SET_SYSTEM); |
| 695 |
if(codeSet == (iconv_t)-1) { |
if(codeSet == (iconv_t)-1) { |
| 696 |
MN_FATAL_ERROR(wxT("failed iconv_open")); |
MN_FATAL_ERROR(wxT("failed iconv_open")); |
| 702 |
MN_FATAL_ERROR(wxT("File open error.")); |
MN_FATAL_ERROR(wxT("File open error.")); |
| 703 |
} |
} |
| 704 |
|
|
| 705 |
memset(inbuf, 0, sizeof(inbuf)); |
memset(inbuf, 0, MAX_WIKI_TEXT_SIZE); |
| 706 |
strcpy(inbuf,(const char*)text->mb_str()); |
strcpy(inbuf,(const char*)text->mb_str()); |
| 707 |
|
|
| 708 |
//#ifdef __WXMAC__ |
//#ifdef __WXMAC__ |
| 712 |
inbufPtr = inbuf; |
inbufPtr = inbuf; |
| 713 |
inbufSize = strlen(inbufPtr); |
inbufSize = strlen(inbufPtr); |
| 714 |
outbufPtr = outbuf; |
outbufPtr = outbuf; |
| 715 |
outbufSize = sizeof(outbuf); |
outbufSize = MAX_WIKI_TEXT_SIZE; |
| 716 |
memset(outbuf, 0, outbufSize); |
memset(outbuf, 0, outbufSize); |
| 717 |
iconv(codeSet, (ICONV_CONST char**)&inbufPtr, (size_t*)&inbufSize, &outbufPtr, (size_t*)&outbufSize); |
iconv(codeSet, (ICONV_CONST char**)&inbufPtr, (size_t*)&inbufSize, &outbufPtr, (size_t*)&outbufSize); |
| 718 |
if(inbufSize != 0) { // iconv error |
if(inbufSize != 0) { // iconv error |
| 719 |
wxMessageBox(wxT("Fail to save, because this memo include KISHU-IZON-MOJI.\nPlease remove KISHU-IZON-MOJI, and try again"), wxT("Fail to save"), wxOK|wxICON_WARNING); |
wxMessageBox(wxT("Fail to save, because this memo include KISHU-IZON-MOJI.\nPlease remove KISHU-IZON-MOJI, and try again"), wxT("Fail to save"), wxOK|wxICON_WARNING); |
| 720 |
} |
} |
| 721 |
fwrite(outbuf, sizeof(outbuf)-outbufSize, 1, fp); |
fwrite(outbuf, MAX_WIKI_TEXT_SIZE-outbufSize, 1, fp); |
| 722 |
fclose(fp); |
fclose(fp); |
| 723 |
iconv_close(codeSet); |
iconv_close(codeSet); |
| 724 |
|
|
| 725 |
|
free(inbuf); |
| 726 |
|
free(outbuf); |
| 727 |
} |
} |
| 728 |
|
|
| 729 |
/******* Tools ************************/ |
/******* Tools ************************/ |