WIP sj4lib
This commit is contained in:
parent
b269c243c8
commit
8fdd90499b
8 changed files with 19247 additions and 26 deletions
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
#include "sj4mkdic.h"
|
||||
|
||||
#include "ucstable.h"
|
||||
#include "sj_ucs2euc.h"
|
||||
|
||||
int bubun_str(u_char* p1, int l1, u_char* p2, int l2) {
|
||||
u_char* p;
|
||||
|
|
@ -204,7 +204,7 @@ void utf8_print(char* out, int c) {
|
|||
|
||||
int unicode_to_eucjp(int utf) {
|
||||
if(0 <= utf && utf <= 0xffff) {
|
||||
const T_BITMAP_INDEX* b = &utf16_to_euc_jp_table[(utf >> 8) & 0xff];
|
||||
const T_U2E_BITMAP_INDEX* b = &utf16_to_euc_jp_table[(utf >> 8) & 0xff];
|
||||
|
||||
if(b->byType == 2) {
|
||||
if(b->dwBitmapIndex != 0) {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,11 +1,12 @@
|
|||
#include <sj_kanakan.h>
|
||||
#include <sj4lib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
char out[64 * 1024];
|
||||
int i = 0;
|
||||
char c[64 * 1024];
|
||||
char b;
|
||||
Sj4Context* ctx = alloccontext("sj4main.dic");
|
||||
char c[8 * 1024];
|
||||
Sj4Lib* ctx = sj4_open(SJ4UTF8, "sj4main.dic");
|
||||
char b;
|
||||
|
||||
if(ctx == NULL) {
|
||||
fprintf(stderr, "Failed to create context\n");
|
||||
|
|
@ -15,7 +16,8 @@ int main(int argc, char** argv) {
|
|||
c[0] = 0;
|
||||
|
||||
while(fread(&b, 1, 1, stdin) == 1) {
|
||||
int n;
|
||||
int n, i;
|
||||
Sj4Kouho kouho;
|
||||
|
||||
if(b == '\n') {
|
||||
} else if(b != '\r') {
|
||||
|
|
@ -28,22 +30,15 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
|
||||
i = 0;
|
||||
while((strlen(c) - i) > 0 && (i += (n = cl2knj(ctx, (u_char*)c + i, strlen(c) - i, (u_char*)out)))) {
|
||||
STDYOUT* s = (STDYOUT*)out;
|
||||
char* str = malloc(n + 1);
|
||||
while((strlen(c) - i) > 0 && (n = sj4_getkan(ctx, c + i, strlen(c + i), &kouho))) {
|
||||
printf("> %s\n", kouho.buffer);
|
||||
|
||||
memcpy(str, c + i - n, n);
|
||||
str[i] = 0;
|
||||
|
||||
printf("> %s -> %s\n", str, out + sizeof(STDYOUT));
|
||||
|
||||
free(str);
|
||||
i += n;
|
||||
}
|
||||
|
||||
c[0] = 0;
|
||||
}
|
||||
|
||||
free_context(ctx);
|
||||
sj4_close(ctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue