Skip to content

Commit 5044c56

Browse files
committed
Support UTF-8 to SJIS conversion
1 parent b1be58a commit 5044c56

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,18 @@ CROSS_COMPILE ?= m68k-xelf-
77
CC = $(CROSS_COMPILE)gcc
88
LD = $(CC)
99

10-
CFLAGS = -Wall -O2 -g $(INC)
10+
CFLAGS = -Wall -O2 -g $(INC) $(DEFS)
1111
LDFLAGS = $(LIBS)
1212
LIBS = -lsocket
1313

1414
AXTLS_DIR = axtls
1515
AXTLS_INCLUDE = axtls-include
1616

17-
INC += -I. -I$(AXTLS_INCLUDE) -I$(AXTLS_DIR)/ssl -I$(AXTLS_DIR)/crypto
17+
INC += -I. -I$(AXTLS_INCLUDE) -I$(AXTLS_DIR)/ssl -I$(AXTLS_DIR)/crypto -Iiconv
18+
DEFS += -DICONV_ONLY_U2S
1819

19-
SRCS += httpsget.c
20+
SRCS += httpsget.c \
21+
iconv/iconv_mini.c
2022

2123
SRCS += $(addprefix $(AXTLS_DIR)/, \
2224
ssl/asn1.c \

httpsget.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
#include <errno.h>
1010
#include <ctype.h>
1111
#include "ssl.h"
12+
#include "iconv/iconv_mini.h"
1213

1314
char request[65536];
1415
char response[65536];
1516
char buffer[4096];
17+
char obuffer[4096];
1618

1719
int main(int argc, char **argv)
1820
{
@@ -127,7 +129,12 @@ int main(int argc, char **argv)
127129
break;
128130
}
129131
// printf("Received %d bytes\n", res);
130-
write(1, ptr, res);
132+
uint8_t *p = ptr;
133+
size_t len = res;
134+
uint8_t *op = (uint8_t *)obuffer;
135+
size_t olen = sizeof(obuffer);
136+
iconv_u2s((char **)&p, &len, (char **)&op, &olen);
137+
fwrite(obuffer, 1, sizeof(obuffer) - olen, stdout);
131138
}
132139

133140
ssl_free(ssl_sock);

0 commit comments

Comments
 (0)