--- ../bbs_gbk_utf8.html 2023-02-11 13:09:55.659432422 +0800 +++ bbs_gbk_utf8.html 2023-02-11 13:29:23.784185878 +0800 @@ -236,49 +236,49 @@
#include <stdio.h> -#include <iconv.h> +#include <stdio.h> +#include <iconv.h> -#define UTF8_SIZE 4 +#define UTF8_SIZE 4 -int -convert_one(iconv_t cd) +int +convert_one(iconv_t cd) { - char inbuf[2] = {0}; - char outbuf[UTF8_SIZE] = {0}; - size_t insize = 1; - size_t outsize = UTF8_SIZE; - - char c = getchar(); - if (c == EOF) - return 1; + char inbuf[2] = {0}; + char outbuf[UTF8_SIZE] = {0}; + size_t insize = 1; + size_t outsize = UTF8_SIZE; + + char c = getchar(); + if (c == EOF) + return 1; inbuf[0] = c; - char * pIn = inbuf; - char * pOut = (char*) outbuf; + char * pIn = inbuf; + char * pOut = (char*) outbuf; - size_t iconv_result = iconv(cd, &pIn, &insize, &pOut, &outsize); - if (iconv_result == (size_t) -1) { + size_t iconv_result = iconv(cd, &pIn, &insize, &pOut, &outsize); + if (iconv_result == (size_t) -1) { inbuf[1] = getchar(); insize = 2; iconv(cd, &pIn, &insize, &pOut, &outsize); } - for (int i = 0; i < UTF8_SIZE; i++) { - if (outbuf[i] != 0) + for (int i = 0; i < UTF8_SIZE; i++) { + if (outbuf[i] != 0) putchar(outbuf[i]); fflush(stdout); } - return 0; + return 0; } -int -main(void) +int +main(void) { - iconv_t cd = iconv_open("UTF8", "GBK"); - while (1) - if (convert_one(cd) == 1) break; + iconv_t cd = iconv_open("UTF8", "GBK"); + while (1) + if (convert_one(cd) == 1) break; iconv_close(cd); - return 0; + return 0; }