Fix warning and Win32 in general
This commit is contained in:
parent
7993ba946c
commit
5e3b8b3b12
7 changed files with 27 additions and 12 deletions
|
|
@ -142,10 +142,16 @@ int codesize(u_char code) {
|
|||
euc[strlen(euc)] = (c); \
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#define TO sj4_to_sjis
|
||||
#else
|
||||
#define TO sj4_to_utf8
|
||||
#endif
|
||||
|
||||
void output_knj(FILE* fp, u_char* p, int l) {
|
||||
u_char euc[64];
|
||||
#ifdef UTF8
|
||||
u_char ucs[64];
|
||||
u_char to[64];
|
||||
#endif
|
||||
euc[0] = 0;
|
||||
|
||||
|
|
@ -203,9 +209,9 @@ void output_knj(FILE* fp, u_char* p, int l) {
|
|||
}
|
||||
|
||||
#ifdef UTF8
|
||||
ucs[sj4_to_utf8(ucs, euc, strlen(euc))] = 0;
|
||||
to[TO(to, euc, strlen(euc))] = 0;
|
||||
|
||||
fputs(ucs, fp);
|
||||
fputs(to, fp);
|
||||
#else
|
||||
fputs(euc, fp);
|
||||
#endif
|
||||
|
|
@ -289,7 +295,7 @@ void output_yomi(FILE* fp, u_char* p) {
|
|||
char buf[5];
|
||||
#ifdef UTF8
|
||||
u_char euc[2];
|
||||
u_char ucs[64];
|
||||
u_char to[64];
|
||||
#endif
|
||||
|
||||
while(*p) {
|
||||
|
|
@ -299,9 +305,9 @@ void output_yomi(FILE* fp, u_char* p) {
|
|||
euc[0] = (i >> 8) & 0xff;
|
||||
euc[1] = i & 0xff;
|
||||
|
||||
ucs[sj4_to_utf8(ucs, euc, 2)] = 0;
|
||||
to[TO(to, euc, 2)] = 0;
|
||||
|
||||
fputs(ucs, fp);
|
||||
fputs(to, fp);
|
||||
#else
|
||||
fputc((i >> 8) & 0xff, fp);
|
||||
fputc(i & 0xff, fp);
|
||||
|
|
|
|||
|
|
@ -2,11 +2,16 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <locale.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define CHARSET SJ4SJIS
|
||||
#else
|
||||
#define CHARSET SJ4UTF8
|
||||
#endif
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
char c[8 * 1024];
|
||||
Sj4Lib* ctx = sj4_open(SJ4UTF8, "sj4main.dic");
|
||||
Sj4Lib* ctx = sj4_open(CHARSET, "sj4main.dic");
|
||||
char b;
|
||||
|
||||
if(ctx == NULL) {
|
||||
|
|
@ -16,8 +21,6 @@ int main(int argc, char** argv) {
|
|||
|
||||
c[0] = 0;
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
while(fread(&b, 1, sizeof(b), stdin)) {
|
||||
int n, i;
|
||||
Sj4Kouho kouho;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue