DllExport int VnConvert(int inCharset, int outCharset, UKBYTE *input, UKBYTE *output, int * pInLen, int * pMaxOutLen) { int inLen, maxOutLen; int ret = -1; inLen = *pInLen; maxOutLen = *pMaxOutLen; if (inLen != -1 && inLen < 0) // invalid inLen return ret; VnCharset *pInCharset = VnCharsetLibObj.getVnCharset(inCharset); VnCharset *pOutCharset = VnCharsetLibObj.getVnCharset(outCharset); if (!pInCharset || !pOutCharset) return VNCONV_INVALID_CHARSET; StringBIStream is(input, inLen, pInCharset->elementSize()); StringBOStream os(output, maxOutLen); ret = genConvert(*pInCharset, *pOutCharset, is, os); *pMaxOutLen = os.getOutBytes(); *pInLen = is.left(); return ret; }
//------------------------------------------------ // Returns: // 0: successful // errCode: if failed //--------------------------------------- int vnFileStreamConvert(int inCharset, int outCharset, FILE * inf, FILE *outf) { VnCharset *pInCharset = VnCharsetLibObj.getVnCharset(inCharset); VnCharset *pOutCharset = VnCharsetLibObj.getVnCharset(outCharset); if (!pInCharset || !pOutCharset) return VNCONV_INVALID_CHARSET; if (outCharset == CONV_CHARSET_UNICODE) { UKWORD sign = 0xFEFF; fwrite(&sign, sizeof(UKWORD), 1, outf); } FileBIStream is; FileBOStream os; is.attach(inf); os.attach(outf); return genConvert(*pInCharset, *pOutCharset, is, os); }