예제 #1
0
PRIVATE void
net_report_autodetect(void *closure, CCCDataObject obj, uint16 doc_csid)
{
	NetStreamData *nsd = (NetStreamData *)closure;
	iDocumentContext  doc_context = nsd->current_stream->window_id;
	CCCFunc cvtfunc = INTL_GetCCCCvtfunc(obj);
	INTL_CharSetInfo c = LO_GetDocumentCharacterSetInfo(doc_context);

	INTL_SetCSIDocCSID(c, doc_csid);
	/* I hope it is okay, to set the win_csid */
	INTL_SetCSIWinCSID(c, INTL_GetCCCToCSID(obj));
	if (cvtfunc == NULL)
		nsd->current_stream->put_block = (MKStreamWriteFunc) net_NoCharCodeConv;
}
예제 #2
0
/*
	buf -> mz_mbNullConv -> frombuf -> INTL_TextToUnicode -> ucs2buf
	-> INTL_UnicodeToStr -> tobuf
*/
PRIVATE unsigned char* mz_AnyToAnyThroughUCS2(CCCDataObject obj, const unsigned char *buf, int32 bufsz)
{
	/* buffers */
	unsigned char* fromBuf = NULL;
	INTL_Unicode* ucs2Buf = NULL;
	unsigned char* toBuf   = NULL;
	/* buffers' length */
	uint32 ucs2BufLen = 0;
	uint32 fromBufLen = 0;
	uint32 toBufLen   = 0;
	/* from & to csid */
	uint16 fromCsid = INTL_GetCCCFromCSID(obj);
	uint16 toCsid   = INTL_GetCCCToCSID(obj);

	/* get the fromBuf */
	if( !( fromBuf = mz_mbNullConv( obj, buf,  bufsz) ) )
		return NULL;

	/* map fromBuf -> ucs2Buf */
	fromBufLen = INTL_GetCCCLen(obj);
	ucs2BufLen = INTL_TextToUnicodeLen( fromCsid, fromBuf, fromBufLen );

	if( !( ucs2Buf = XP_ALLOC( (ucs2BufLen + 1 ) * 2)) ){
		return NULL;
	}

	/* be care, the return value is HOW MANY UNICODE IN THIS UCS2BUF, not how many bytes */
	ucs2BufLen = INTL_TextToUnicode( fromCsid, fromBuf, fromBufLen, ucs2Buf, ucs2BufLen );

	/* map ucs2Buf -> toBuf */
	toBufLen = INTL_UnicodeToStrLen( toCsid, ucs2Buf, ucs2BufLen );	/* we get BYTES here :) */

	if( !( toBuf = XP_ALLOC( toBufLen + 1 ) ) )
		return NULL;

	INTL_UnicodeToStr( toCsid, ucs2Buf, ucs2BufLen, toBuf, toBufLen );


	/* clean up after myself */
	free( fromBuf );
	free( ucs2Buf );

	/* In order to let the caller know how long the buffer is, i have to set its tail NULL. */
	toBuf[ toBufLen ] = 0;
	return toBuf;
}