Ejemplo n.º 1
0
void ARRAY_TEXT::convertFromUTF8(const CUTF8String* fromString, CUTF16String* toString)	
{
#ifdef _WIN32
	int len = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)fromString->c_str(), fromString->length(), NULL, 0);
	
	if(len){
		std::vector<uint8_t> buf((len + 1) * sizeof(PA_Unichar));
		if(MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)fromString->c_str(), fromString->length(), (LPWSTR)&buf[0], len)){
			*toString = CUTF16String((const PA_Unichar *)&buf[0]);
		}
    }else{
			*toString = CUTF16String((const PA_Unichar *)L"");
	}
           
#else
           CFStringRef str = CFStringCreateWithBytes(kCFAllocatorDefault, fromString->c_str(), fromString->length(), kCFStringEncodingUTF8, true);
           if(str){
               int len = CFStringGetLength(str)+1;
               std::vector<uint8_t> buf(len * sizeof(PA_Unichar));
               CFStringGetCharacters(str, CFRangeMake(0, len), (UniChar *)&buf[0]);
               *toString = CUTF16String((const PA_Unichar *)&buf[0]);
               CFRelease(str);
           }
#endif	
}
Ejemplo n.º 2
0
void ARRAY_TEXT::copyUTF16StringAtIndex(CUTF16String* pString, uint32_t index)
{	
	if(index < this->_CUTF16StringArray->size())
	{
		*pString = CUTF16String(this->_CUTF16StringArray->at(index));
	}
}
Ejemplo n.º 3
0
void ARRAY_TEXT::fromParamAtIndex(PackagePtr pParams, uint32_t index)
{	
	if(index)		
	{
		PA_Variable arr = *((PA_Variable*) pParams[index - 1]);
		
		this->setSize(0);		
		
		if(arr.fType == eVK_ArrayUnicode)
		{	
			uint32_t i;
			
			PA_Unistring str;
			
			for(i = 0; i <= (uint32_t)arr.uValue.fArray.fNbElements; i++)
			{				
				str = (*(PA_Unistring **) (arr.uValue.fArray.fData))[i];
				CUTF16String u = CUTF16String(str.fString, str.fLength);
				this->_CUTF16StringArray->push_back(u);
			}
			
		}

	}
	
}
Ejemplo n.º 4
0
	//--------------------------------------------------------------------------------
	CUTF16String CUTF16String::Mid( unsigned short usPos, short usLen )
	{
		CUTF16Char Begin = CharAt( usPos );
		CUTF16Char End( Begin );
		End += usLen;
		return CUTF16String( m_String.Mid( static_cast< unsigned short >( Begin.ptr() - m_String.GetBuffer() ), static_cast< unsigned short >( End.ptr() - Begin.ptr() ) ) );
	}
Ejemplo n.º 5
0
void ARRAY_TEXT::copyUTF8StringAtIndex(CUTF8String* pString, uint32_t index)
{	
	if(index < this->_CUTF16StringArray->size())
	{
		CUTF16String s = CUTF16String(this->_CUTF16StringArray->at(index));
		convertToUTF8(&s, pString);		
	}
}
Ejemplo n.º 6
0
void ARRAY_TEXT::setUTF16StringAtIndex(CUTF16String* pString, uint32_t index)
{
	if(index < this->_CUTF16StringArray->size())
	{		
		CUTF16String str;
		
		if(pString->c_str())
		{
			str = CUTF16String(pString->c_str(), pString->length());
		}else{
			str = CUTF16String();		
		}
		
		std::vector<CUTF16String>::iterator it = this->_CUTF16StringArray->begin();
		it += index;
		this->_CUTF16StringArray->insert(this->_CUTF16StringArray->erase(it), str);	
	}
}
Ejemplo n.º 7
0
void ARRAY_TEXT::appendUTF16String(const PA_Unistring* pString)
{
	CUTF16String u = CUTF16String(pString->fString, pString->fLength);
	this->_CUTF16StringArray->push_back(u);	
}
Ejemplo n.º 8
0
void ARRAY_TEXT::appendUTF16String(CUTF16String* pString)
{
	CUTF16String u = CUTF16String(pString->c_str(), pString->length());	
	this->_CUTF16StringArray->push_back(u);		
}
Ejemplo n.º 9
0
void ARRAY_TEXT::setUTF16StringAtIndex(const PA_Unichar* pString, uint32_t index)
{
	CUTF16String u = CUTF16String(pString);
	this->_CUTF16StringArray->push_back(u);		
}
Ejemplo n.º 10
0
void ARRAY_TEXT::appendUTF16String(const PA_Unichar* pString, uint32_t len)
{
	CUTF16String u = CUTF16String(pString, len);
	this->_CUTF16StringArray->push_back(u);		
}
Ejemplo n.º 11
0
void ARRAY_TEXT::setUTF16StringAtIndex(const PA_Unichar* pString, uint32_t len, uint32_t index)
{
	CUTF16String u;
	u = CUTF16String(pString, (size_t)len);	
	this->setUTF16StringAtIndex(&u, index);
}
Ejemplo n.º 12
0
	//--------------------------------------------------------------------------------
	CUTF16String CUTF16String::Right( unsigned short usLen )
	{
		CUTF16Char Pos = CharAt( m_usCharCount - usLen );
		CUTF16Char End = --end();
		return CUTF16String( m_String.Right( static_cast< unsigned short >( End.ptr() - Pos.ptr() ) ) );
	}