language.c 695 B

1234567891011121314151617181920212223242526272829
  1. #include "language.h"
  2. #include "strnormalize.h"
  3. #include "unicode.h"
  4. #include <string.h>
  5. char Utf8ToGbkOrUnicode(char *ibuf, int inlen,char *outbuf, int *outlen, char codetype){
  6. int outsize=*outlen;
  7. if(0>utf8_to_gbk(ibuf, inlen, outbuf, outlen)) return 1;
  8. if(0!=codetype){
  9. memcpy(ibuf, outbuf,*outlen);
  10. *outlen=2*Ansi_to_Unicode((uint16_t *)outbuf, outsize/2,ibuf, *outlen);
  11. }
  12. return 0;
  13. }
  14. void gbkToUnicode(char *inbuf, int inlen, char *outbuf, int *outlen){
  15. *outlen=Ansi_to_Unicode((uint16_t *)outbuf, *outlen/2,inbuf, inlen);
  16. }
  17. void unicodeToGbk(const char *inbuf, unsigned char *outbuf, unsigned short *outlen){
  18. *outlen=StrUnicodeToAnsi(outbuf, *outlen, inbuf);
  19. }