Esempio n. 1
0
File: UArray.c Progetto: bomma/io
void UArray_convertToEncoding_(UArray *self, CENCODING encoding)
{
	switch(encoding)
	{
		case CENCODING_ASCII:
		case CENCODING_UTF8:
			UArray_convertToUTF8(self);
			break;
		case CENCODING_UCS2:
			UArray_convertToUCS2(self);
			break;
		case CENCODING_UCS4:
			UArray_convertToUCS4(self);
			break;
		case CENCODING_NUMBER:
			UArray_setItemType_(self, CTYPE_uint8_t);
			break;
	}

	self->encoding = encoding;
	UArray_changed(self);
}
Esempio n. 2
0
int UArray_convertToFixedSizeType(UArray *self)
{
    if (self->encoding == CENCODING_UTF8)
    {
        int maxCharSize = UArray_maxCharSize(self);

        if (maxCharSize == 1)
        {
            self->encoding = CENCODING_ASCII;
        }
        else if(maxCharSize == 2)
        {
            UArray_convertToUCS2(self);
        }
        else
        {
            UArray_convertToUCS4(self);
        }

        return 1;
    }

    return 0;
}