src/PowerAuth/Password.cpp
/**
	 Converts one UTF codepoint into sequence of UTF8 encoded bytes.
	 */
Converts one UTF codepoint into sequence of UTF8 encoded bytes.
Converts one UTF codepoint into sequence of UTF8 encoded bytes .
static bool _UTF8Encode(cc7::U32 codepoint, cc7::ByteArray & out)
	{
		cc7::byte buffer[4];
		if(codepoint < 0x80) {
			buffer[0] = (char)codepoint;
			out.append(buffer, 1);
		} else if(codepoint < 0x800) {
			buffer[0] = 0xC0 + ((codepoint & 0x7C0) >> 6);
			buffer[1] = 0x80 + ((codepoint & 0x03F));
			out.append(buffer, 2);
		} else if(codepoint < 0x10000) {
			buffer[0] = 0xE0 + ((codepoint & 0xF000) >> 12);
			buffer[1] = 0x80 + ((codepoint & 0x0FC0) >> 6);
			buffer[2] = 0x80 + ((codepoint & 0x003F));
			out.append(buffer, 3);
		} else if(codepoint <= 0x10FFFF) {
			buffer[0] = 0xF0 + ((codepoint & 0x1C0000) >> 18);
			buffer[1] = 0x80 + ((codepoint & 0x03F000) >> 12);
			buffer[2] = 0x80 + ((codepoint & 0x000FC0) >> 6);
			buffer[3] = 0x80 + ((codepoint & 0x00003F));
			out.append(buffer, 4);
		} else {
			return false;
		}
		return true;
	}
static bool _UTF8Encode ( cc7 :: U32 codepoint , cc7 :: ByteArray & out ) { cc7 :: byte buffer [ 4 ] ; if ( codepoint < 0x80 ) { buffer [ 0 ] = ( char ) codepoint ; out . append ( buffer , 1 ) ; } else if ( codepoint < 0x800 ) { buffer [ 0 ] = 0xC0 + ( ( codepoint & 0x7C0 ) >> 6 ) ; buffer [ 1 ] = 0x80 + ( ( codepoint & 0x03F ) ) ; out . append ( buffer , 2 ) ; } else if ( codepoint < 0x10000 ) { buffer [ 0 ] = 0xE0 + ( ( codepoint & 0xF000 ) >> 12 ) ; buffer [ 1 ] = 0x80 + ( ( codepoint & 0x0FC0 ) >> 6 ) ; buffer [ 2 ] = 0x80 + ( ( codepoint & 0x003F ) ) ; out . append ( buffer , 3 ) ; } else if ( codepoint <= 0x10FFFF ) { buffer [ 0 ] = 0xF0 + ( ( codepoint & 0x1C0000 ) >> 18 ) ; buffer [ 1 ] = 0x80 + ( ( codepoint & 0x03F000 ) >> 12 ) ; buffer [ 2 ] = 0x80 + ( ( codepoint & 0x000FC0 ) >> 6 ) ; buffer [ 3 ] = 0x80 + ( ( codepoint & 0x00003F ) ) ; out . append ( buffer , 4 ) ; } else { return false ; } return true ; }
Converts one UTF codepoint into sequence of UTF8 encoded bytes.
Converts one UTF codepoint into sequence of UTF8 encoded bytes .