wmc: Add support for utf-8 codepage.
This commit is contained in:
parent
2bfdff198c
commit
52f81c12db
|
@ -155,7 +155,7 @@ void set_codepage(int cp)
|
||||||
{
|
{
|
||||||
codepage = cp;
|
codepage = cp;
|
||||||
codepage_def = find_codepage(codepage);
|
codepage_def = find_codepage(codepage);
|
||||||
if(!codepage_def)
|
if(!codepage_def && codepage != CP_UTF8)
|
||||||
xyyerror("Codepage %d not found; cannot process\n", codepage);
|
xyyerror("Codepage %d not found; cannot process\n", codepage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,8 +200,10 @@ try_again:
|
||||||
xyyerror(err_fatalread);
|
xyyerror(err_fatalread);
|
||||||
else if(!cptr)
|
else if(!cptr)
|
||||||
return 0;
|
return 0;
|
||||||
assert(codepage_def != NULL);
|
if (codepage_def)
|
||||||
n = wine_cp_mbstowcs(codepage_def, 0, xlatebuffer, strlen(xlatebuffer)+1, inputbuffer, INPUTBUFFER_SIZE);
|
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)
|
if(n < 0)
|
||||||
internal_error(__FILE__, __LINE__, "Could not translate to unicode (%d)\n", n);
|
internal_error(__FILE__, __LINE__, "Could not translate to unicode (%d)\n", n);
|
||||||
if(n <= 1)
|
if(n <= 1)
|
||||||
|
|
|
@ -251,12 +251,12 @@ cmaps : cmap
|
||||||
;
|
;
|
||||||
|
|
||||||
cmap : clan '=' tNUMBER ':' tNUMBER {
|
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))
|
if(find_cpxlat($1))
|
||||||
xyyerror("Codepage translation already defined for language 0x%x\n", $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);
|
xyyerror(err_nocp, $3);
|
||||||
if($5 && !find_codepage($5))
|
if($5 && $5 != CP_UTF8 && !find_codepage($5))
|
||||||
xyyerror(err_nocp, $5);
|
xyyerror(err_nocp, $5);
|
||||||
add_cpxlat($1, $3, $5);
|
add_cpxlat($1, $3, $5);
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,11 +100,17 @@ static char *dup_u2c(int cp, const WCHAR *uc)
|
||||||
int len;
|
int len;
|
||||||
char *cptr;
|
char *cptr;
|
||||||
const union cptable *cpdef = find_codepage(cp);
|
const union cptable *cpdef = find_codepage(cp);
|
||||||
if(!cpdef)
|
|
||||||
internal_error(__FILE__, __LINE__, "Codepage %d not found (vanished?)\n", cp);
|
if(cpdef)
|
||||||
len = wine_cp_wcstombs(cpdef, 0, uc, unistrlen(uc)+1, NULL, 0, NULL, NULL);
|
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);
|
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);
|
internal_error(__FILE__, __LINE__, "Buffer overflow? code %d\n", len);
|
||||||
return cptr;
|
return cptr;
|
||||||
}
|
}
|
||||||
|
@ -385,8 +391,10 @@ static char *make_string(WCHAR *uc, int len, int codepage)
|
||||||
int mlen;
|
int mlen;
|
||||||
const union cptable *cpdef = find_codepage(codepage);
|
const union cptable *cpdef = find_codepage(codepage);
|
||||||
|
|
||||||
assert(cpdef != NULL);
|
if (cpdef)
|
||||||
mlen = wine_cp_wcstombs(cpdef, 0, uc, unistrlen(uc)+1, NULL, 0, NULL, NULL);
|
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);
|
cc = tmp = xmalloc(mlen);
|
||||||
if((i = wine_cp_wcstombs(cpdef, 0, uc, unistrlen(uc)+1, tmp, mlen, NULL, NULL)) < 0)
|
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);
|
internal_error(__FILE__, __LINE__, "Buffer overflow? code %d\n", i);
|
||||||
|
|
Loading…
Reference in New Issue