diff --git a/tools/wmc/mcl.c b/tools/wmc/mcl.c index be016914c77..7be41d51925 100644 --- a/tools/wmc/mcl.c +++ b/tools/wmc/mcl.c @@ -155,7 +155,7 @@ void set_codepage(int cp) { codepage = cp; codepage_def = find_codepage(codepage); - if(!codepage_def) + if(!codepage_def && codepage != CP_UTF8) xyyerror("Codepage %d not found; cannot process\n", codepage); } @@ -200,8 +200,10 @@ try_again: xyyerror(err_fatalread); else if(!cptr) return 0; - assert(codepage_def != NULL); - n = wine_cp_mbstowcs(codepage_def, 0, xlatebuffer, strlen(xlatebuffer)+1, inputbuffer, INPUTBUFFER_SIZE); + if (codepage_def) + n = wine_cp_mbstowcs(codepage_def, 0, xlatebuffer, strlen(xlatebuffer)+1, inputbuffer, INPUTBUFFER_SIZE); + else + n = wine_utf8_mbstowcs(0, xlatebuffer, strlen(xlatebuffer)+1, inputbuffer, INPUTBUFFER_SIZE); if(n < 0) internal_error(__FILE__, __LINE__, "Could not translate to unicode (%d)\n", n); if(n <= 1) diff --git a/tools/wmc/mcy.y b/tools/wmc/mcy.y index 2887df56b6d..5de67c943c8 100644 --- a/tools/wmc/mcy.y +++ b/tools/wmc/mcy.y @@ -251,12 +251,12 @@ cmaps : cmap ; cmap : clan '=' tNUMBER ':' tNUMBER { - static const char err_nocp[] = "Codepage %d not builtin; cannot convert"; + static const char err_nocp[] = "Codepage %d not builtin; cannot convert\n"; if(find_cpxlat($1)) xyyerror("Codepage translation already defined for language 0x%x\n", $1); - if($3 && !find_codepage($3)) + if($3 && $3 != CP_UTF8 && !find_codepage($3)) xyyerror(err_nocp, $3); - if($5 && !find_codepage($5)) + if($5 && $5 != CP_UTF8 && !find_codepage($5)) xyyerror(err_nocp, $5); add_cpxlat($1, $3, $5); } diff --git a/tools/wmc/write.c b/tools/wmc/write.c index 7df242466d3..22858b8871e 100644 --- a/tools/wmc/write.c +++ b/tools/wmc/write.c @@ -100,11 +100,17 @@ static char *dup_u2c(int cp, const WCHAR *uc) int len; char *cptr; const union cptable *cpdef = find_codepage(cp); - if(!cpdef) - internal_error(__FILE__, __LINE__, "Codepage %d not found (vanished?)\n", cp); - len = wine_cp_wcstombs(cpdef, 0, uc, unistrlen(uc)+1, NULL, 0, NULL, NULL); + + if(cpdef) + len = wine_cp_wcstombs(cpdef, 0, uc, unistrlen(uc)+1, NULL, 0, NULL, NULL); + else + len = wine_utf8_wcstombs(0, uc, unistrlen(uc)+1, NULL, 0); cptr = xmalloc(len); - if((len = wine_cp_wcstombs(cpdef, 0, uc, unistrlen(uc)+1, cptr, len, NULL, NULL)) < 0) + if (cpdef) + len = wine_cp_wcstombs(cpdef, 0, uc, unistrlen(uc)+1, cptr, len, NULL, NULL); + else + len = wine_utf8_wcstombs(0, uc, unistrlen(uc)+1, cptr, len); + if (len < 0) internal_error(__FILE__, __LINE__, "Buffer overflow? code %d\n", len); return cptr; } @@ -385,8 +391,10 @@ static char *make_string(WCHAR *uc, int len, int codepage) int mlen; const union cptable *cpdef = find_codepage(codepage); - assert(cpdef != NULL); - mlen = wine_cp_wcstombs(cpdef, 0, uc, unistrlen(uc)+1, NULL, 0, NULL, NULL); + if (cpdef) + mlen = wine_cp_wcstombs(cpdef, 0, uc, unistrlen(uc)+1, NULL, 0, NULL, NULL); + else + mlen = wine_utf8_wcstombs(0, uc, unistrlen(uc)+1, NULL, 0); cc = tmp = xmalloc(mlen); if((i = wine_cp_wcstombs(cpdef, 0, uc, unistrlen(uc)+1, tmp, mlen, NULL, NULL)) < 0) internal_error(__FILE__, __LINE__, "Buffer overflow? code %d\n", i);