/* Converts an ucs1 string into an utf8 string.  */
enum CRStatus cr_utils_ucs1_str_to_utf8(const guchar *a_in, gulong *a_in_len, guchar **a_out, gulong *a_out_len)
/* Converts an ucs1 string into an utf8 string.  */
enum CRStatus cr_utils_ucs1_str_to_utf8(const guchar *a_in, gulong *a_in_len, guchar **a_out, gulong *a_out_len)
{
        gulong in_len = 0,
                out_len = 0;
        enum CRStatus status = CR_OK;
        g_return_val_if_fail (a_in && a_in_len && a_out
                              && a_out_len, CR_BAD_PARAM_ERROR);
        if (*a_in_len < 1) {
                *a_out_len = 0;
                *a_out = NULL;
                return CR_OK;
        }
        status = cr_utils_ucs1_str_len_as_utf8 (a_in, &a_in[*a_in_len - 1],
                                                &out_len);
        g_return_val_if_fail (status == CR_OK, status);
        in_len = *a_in_len;
        *a_out = g_malloc0 (out_len);
        status = cr_utils_ucs1_to_utf8 (a_in, a_in_len, *a_out, &out_len);
        *a_out_len = out_len;
        return status;
}