Exemplo n.º 1
0
jstring LMBCStoJavaString(JNIEnv *env, const char *str, int len)
{
	if(str) {
		if (!*str) {
			len = 0;
		}

		WORD pSize = len == 0 ? SIZET_TO_WORD(strlen(str)) : len;
		jchar localBuffer[2048];
		jchar* unicodeBuffer;
		jstring jStr = NULL;

		if (sizeof(jchar)*(pSize+1) < sizeof (localBuffer)) {
			unicodeBuffer = localBuffer;
			memset (localBuffer, 0, sizeof (localBuffer));
		} else {
			unicodeBuffer = (jchar*)MemAlloc(sizeof(jchar)*(pSize+1));
		}

		if (unicodeBuffer != NULL) {
			pSize = OSTranslate(OS_TRANSLATE_LMBCS_TO_UNICODE,str,pSize,(char*)unicodeBuffer,((pSize + 1) * sizeof (jchar)));
			jStr = env->NewString(unicodeBuffer, pSize/sizeof(jchar));
			if (unicodeBuffer != localBuffer) {
				MemFree(unicodeBuffer);
			}
		}
		return jStr;
	}

	return NULL;
}
Exemplo n.º 2
0
DWORD CLotusNote::LogLotusErrorMsg(STATUS sr,char* msg)
{
	if (msg != NULL) glog.log_strings(LOG_ERROR,msg);
	if (sr != NOERROR)
	{
		glog.log_strings(LOG_ERROR,"Lotus message ->",false);
		OSLoadString(NULLHANDLE,ERR(sr),m_err_msg,sizeof(m_err_msg));
		OSTranslate(OS_TRANSLATE_LMBCS_TO_NATIVE,m_err_msg,sizeof(m_err_msg),m_err_msg,sizeof(m_err_msg));
		glog.log_strings(LOG_ERROR,m_err_msg);
	}
	return ERR_API;
}
Exemplo n.º 3
0
char* CLNotesError::getErrorString(STATUS ecode)
{
	if (ecode != NOERROR)
	{
		int		len;
		
		OSLoadString(NULLHANDLE,ERR(ecode),m_err_str,sizeof(m_err_str)-1);
		len = strlen(m_err_str);
		OSTranslate(OS_TRANSLATE_LMBCS_TO_NATIVE,m_err_str,len,m_err_str,len);
	}
	else
		*m_err_str = 0;
	return m_err_str;
	
}
Exemplo n.º 4
0
void JStringLMBCS::init(JNIEnv* env, const jchar* jc, int length) {
	this->data = NULL;
	if(length > 0) {
		// Allocate the buffer that will receive the LMBCS characters
		// *3 is safe enough, but the actual string will certainly be shorter
		WORD pSize = length*3;
		if (sizeof(char)*(pSize+1) < sizeof (localBuffer)) {
			data = localBuffer;
			memset (localBuffer, 0, sizeof (localBuffer));
		} else {
			data = (char*)MemAlloc(sizeof(char)*(pSize+1));
		}

		if (data != NULL) {
			pSize = OSTranslate(OS_TRANSLATE_UNICODE_TO_LMBCS,(const char*)jc,length*sizeof(jchar),(char*)data,((pSize + 1) * sizeof (char)));
			data[pSize] = 0;
		}
	}
}