Ejemplo n.º 1
0
void capitalize(int line_num, struct eia608_screen *data)
{
	for (int i = 0; i<CCX_DECODER_608_SCREEN_WIDTH; i++)
	{
		switch (data->characters[line_num][i])
		{
		case ' ':
		case 0x89: // This is a transparent space
		case '-':
			break;
		case '.': // Fallthrough
		case '?': // Fallthrough
		case '!':
		case ':':
			new_sentence = 1;
			break;
		default:
			if (new_sentence)
				data->characters[line_num][i] = cctoupper(data->characters[line_num][i]);
			else
				data->characters[line_num][i] = cctolower(data->characters[line_num][i]);
			new_sentence = 0;
			break;
		}
	}
}
Ejemplo n.º 2
0
int clever_capitalize(struct encoder_ctx *context, int line_num, struct eia608_screen *data)
{
	// CFS: Tried doing to clever (see below) but some channels do all uppercase except for
	// notes for deaf people (such as "(narrator)" which messes things up.
		// First find out if we actually need to do it, don't mess with lines that come OK
		//int doit = is_all_caps(context, line_num, data);
	int doit = 1;

	for (int i = 0; i < CCX_DECODER_608_SCREEN_WIDTH; i++)
	{
		switch (data->characters[line_num][i])
		{
		case ' ':
		case 0x89: // This is a transparent space
		case '-':
			break;
		case '.': // Fallthrough
		case '?': // Fallthrough
		case '!':
		case ':':
			context->new_sentence = 1;
			break;
		default:
			if (doit)
			{
				if (context->new_sentence)
					data->characters[line_num][i] = cctoupper(data->characters[line_num][i]);
				else
					data->characters[line_num][i] = cctolower(data->characters[line_num][i]);
			}
			context->new_sentence = 0;
			break;
		}
	}
	return doit;
}