\\r\\n\",(unsigned long long)ms_start);","\tif (context->encoding != CCX_ENC_UNICODE)","\t{","\t\tdbg_print(CCX_DMT_DECODER_608, \"\\r%s\\n\", str);","\t}","","\tused = encode_line(context, context->buffer, (unsigned char *) str);","\tret = write (context->out->fh, context->buffer, used);","\tif(ret != used)","\t{","\t\treturn ret;","\t}","","\tlen = strlen (string);","\tunescaped= (unsigned char *) malloc (len+1);","\tif(!unescaped)","\t{","\t\tmprint (\"In write_stringz_as_sami() - not enough memory for len %d.\\n\", len);","\t\tret = -1;","\t\tgoto end;","\t}","","\tel = (unsigned char *) malloc (len*3+1); // Be generous","\tif (el == NULL)","\t{","\t\tmprint (\"In write_stringz_as_sami() - not enough memory for len %d.\\n\", len);","\t\tret = -1;","\t\tgoto end;","\t}","","\tint pos_r=0;","\tint pos_w=0;","\t// Scan for \\n in the string and replace it with a 0","\twhile (pos_r < len)","\t{","\t\tif (string[pos_r] == '\\\\' && string[pos_r+1]=='n')","\t\t{","\t\t\tunescaped[pos_w] = 0;","\t\t\tpos_r += 2;","\t\t}","\t\telse","\t\t{","\t\t\tunescaped[pos_w] = string[pos_r];","\t\t\tpos_r++;","\t\t}","\t\tpos_w++;","\t}","\tunescaped[pos_w] = 0;","\t// Now read the unescaped string (now several string'z and write them)","\tunsigned char *begin = unescaped;","\twhile (begin < unescaped+len)","\t{","\t\tunsigned int u = encode_line (context, el, begin);","\t\tif (context->encoding != CCX_ENC_UNICODE)","\t\t{","\t\t\tdbg_print(CCX_DMT_DECODER_608, \"\\r\");","\t\t\tdbg_print(CCX_DMT_DECODER_608, \"%s\\n\",context->subline);","\t\t}","\t\tret = write(context->out->fh, el, u);","\t\tif(ret != u)","\t\t\tgoto end;","","\t\tret = write(context->out->fh, context->encoded_br, context->encoded_br_length);","\t\tif(ret != context->encoded_br_length)","\t\t\tgoto end;","","\t\tret = write(context->out->fh, context->encoded_crlf, context->encoded_crlf_length);","\t\tif(ret != context->encoded_crlf_length)","\t\t\tgoto end;","","\t\tbegin += strlen ((const char *) begin) + 1;","\t}","","\tsprintf ((char *) str, \"
\\r\\n\"","\t\t\t, (unsigned long long) sub->start_time);","\t\twrite(context->out->fh, buf, strlen(buf));","\t\tfor (int i = sub->nb_data - 1; i >= 0; i--)","\t\t{","\t\t\tif (rect[i].ocr_text && *(rect[i].ocr_text))","\t\t\t{","\t\t\t\tif (context->prev_start != -1 || !(sub->flags & SUB_EOD_MARKER))","\t\t\t\t{","\t\t\t\t\ttoken = strtok(rect[i].ocr_text, \"\\r\\n\");","\t\t\t\t\tsprintf(buf, \"%s\", token);","\t\t\t\t\ttoken = strtok(NULL, \"\\r\\n\");","\t\t\t\t\twrite(context->out->fh, buf, strlen(buf));","\t\t\t\t\tif (i != 0)","\t\t\t\t\t\twrite(context->out->fh, context->encoded_br, context->encoded_br_length);","\t\t\t\t\twrite(context->out->fh, context->encoded_crlf, context->encoded_crlf_length);","\t\t\t\t}","\t\t\t}","\t\t}","\t\tsprintf(buf, \"
\\r\\n\",","\t\t\t(unsigned long long)data->start_time);","\tif (context->encoding != CCX_ENC_UNICODE)","\t{","\t\tdbg_print(CCX_DMT_DECODER_608, \"\\r%s\\n\", str);","\t}","\tused = encode_line(context, context->buffer,(unsigned char *) str);","\twrite (context->out->fh, context->buffer, used);","\tfor (int i=0;i<15;i++)","\t{","\t\tif (data->row_used[i])","\t\t{","\t\t\tint length = get_decoder_line_encoded (context, context->subline, i, data);","\t\t\tif (context->encoding != CCX_ENC_UNICODE)","\t\t\t{","\t\t\t\tdbg_print(CCX_DMT_DECODER_608, \"\\r\");","\t\t\t\tdbg_print(CCX_DMT_DECODER_608, \"%s\\n\",context->subline);","\t\t\t}","\t\t\twrite (context->out->fh, context->subline, length);","\t\t\twrote_something = 1;","\t\t\tif (i!=14)","\t\t\t\twrite (context->out->fh, context->encoded_br, context->encoded_br_length);","\t\t\twrite (context->out->fh, context->encoded_crlf, context->encoded_crlf_length);","\t\t}","\t}","\tsprintf ((char *) str,\"