wmc: Always output resource strings in Unicode format.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
ccfabb323b
commit
f504135e38
|
@ -188,14 +188,6 @@ const language_t *find_language(unsigned id)
|
|||
|
||||
#ifdef _WIN32
|
||||
|
||||
static BOOL CALLBACK proc( char *cp )
|
||||
{
|
||||
CPINFOEXA info;
|
||||
GetCPInfoExA( atoi(cp), 0, &info );
|
||||
printf("%-5s %s\n", cp, info.CodePageName );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int is_valid_codepage(int id)
|
||||
{
|
||||
return IsValidCodePage( id );
|
||||
|
@ -206,11 +198,6 @@ int wmc_mbstowcs( int codepage, int flags, const char *src, int srclen, WCHAR *d
|
|||
return MultiByteToWideChar( codepage, flags, src, srclen, dst, dstlen );
|
||||
}
|
||||
|
||||
int wmc_wcstombs( int codepage, int flags, const WCHAR *src, int srclen, char *dst, int dstlen )
|
||||
{
|
||||
return WideCharToMultiByte( codepage, flags, src, srclen, dst, dstlen, NULL, NULL );
|
||||
}
|
||||
|
||||
#else /* _WIN32 */
|
||||
|
||||
#include "wine/unicode.h"
|
||||
|
@ -225,9 +212,4 @@ int wmc_mbstowcs( int codepage, int flags, const char *src, int srclen, WCHAR *d
|
|||
return wine_cp_mbstowcs( wine_cp_get_table( codepage ), flags, src, srclen, dst, dstlen );
|
||||
}
|
||||
|
||||
int wmc_wcstombs( int codepage, int flags, const WCHAR *src, int srclen, char *dst, int dstlen )
|
||||
{
|
||||
return wine_cp_wcstombs( wine_cp_get_table( codepage ), flags, src, srclen, dst, dstlen, NULL, NULL );
|
||||
}
|
||||
|
||||
#endif /* _WIN32 */
|
||||
|
|
|
@ -34,6 +34,5 @@ void show_languages(void);
|
|||
const language_t *find_language(unsigned id);
|
||||
int is_valid_codepage(int id);
|
||||
int wmc_mbstowcs( int codepage, int flags, const char *src, int srclen, WCHAR *dst, int dstlen );
|
||||
int wmc_wcstombs( int codepage, int flags, const WCHAR *src, int srclen, char *dst, int dstlen );
|
||||
|
||||
#endif
|
||||
|
|
|
@ -590,7 +590,7 @@ static lan_blk_t *block_messages(node_t *head)
|
|||
int nmsg = 0;
|
||||
int i;
|
||||
int nl;
|
||||
int factor = unicodeout ? 2 : 1;
|
||||
int factor = 2;
|
||||
|
||||
for(ndp = head; ndp; ndp = ndp->next)
|
||||
{
|
||||
|
|
|
@ -93,11 +93,6 @@ int pedantic = 0;
|
|||
*/
|
||||
int unicodein = 0;
|
||||
|
||||
/*
|
||||
* Unicode output (-U option)
|
||||
*/
|
||||
int unicodeout = 0;
|
||||
|
||||
/*
|
||||
* Inline the messagetables (don't write *.bin files; -i option)
|
||||
*/
|
||||
|
@ -249,8 +244,7 @@ int main(int argc,char *argv[])
|
|||
case 'u':
|
||||
unicodein = 1;
|
||||
break;
|
||||
case 'U':
|
||||
unicodeout = 1;
|
||||
case 'U': /* ignored for backwards compatibility */
|
||||
break;
|
||||
case 'v':
|
||||
show_languages();
|
||||
|
@ -295,7 +289,6 @@ int main(int argc,char *argv[])
|
|||
else if (output_name && strendswith( output_name, ".pot" )) output_format = FORMAT_POT;
|
||||
else output_format = FORMAT_RC;
|
||||
}
|
||||
if (output_format == FORMAT_RES) unicodeout = 1;
|
||||
|
||||
/* Generate appropriate outfile names */
|
||||
if(!output_name)
|
||||
|
|
|
@ -42,7 +42,6 @@ extern int byteorder;
|
|||
extern int decimal;
|
||||
extern int custombit;
|
||||
extern int unicodein;
|
||||
extern int unicodeout;
|
||||
extern int rcinline;
|
||||
|
||||
extern char *output_name;
|
||||
|
|
|
@ -59,10 +59,8 @@ gettext convention, in particular in must contain one \fI.po\fR file for
|
|||
each language, and a LINGUAS file listing the available languages.
|
||||
.TP
|
||||
.B \-u
|
||||
Assume that the inputfile is in unicode.
|
||||
.TP
|
||||
.B \-U
|
||||
Write resource output in unicode formatted messagetable(s).
|
||||
Assume that the input file is in Unicode or UTF-8 format and skip
|
||||
codepage conversions.
|
||||
.TP
|
||||
.B \-v
|
||||
Show all supported codepages and languages.
|
||||
|
|
|
@ -306,131 +306,67 @@ static void write_rcbin(FILE *fp)
|
|||
}
|
||||
}
|
||||
|
||||
static char *make_string(WCHAR *uc, int len, int codepage)
|
||||
static char *make_string(WCHAR *uc, int len)
|
||||
{
|
||||
char *str = xmalloc(7*len + 1);
|
||||
char *cptr = str;
|
||||
int i;
|
||||
int b;
|
||||
char *str = xmalloc(7*len + 12);
|
||||
char *cptr = str;
|
||||
int i;
|
||||
int b;
|
||||
|
||||
if (!codepage || codepage == CP_UTF8)
|
||||
{
|
||||
*cptr++ = ' ';
|
||||
*cptr++ = 'L';
|
||||
*cptr++ = '"';
|
||||
for(i = b = 0; i < len; i++, uc++)
|
||||
{
|
||||
switch(*uc)
|
||||
{
|
||||
case '\a': *cptr++ = '\\'; *cptr++ = 'a'; b += 2; break;
|
||||
case '\b': *cptr++ = '\\'; *cptr++ = 'b'; b += 2; break;
|
||||
case '\f': *cptr++ = '\\'; *cptr++ = 'f'; b += 2; break;
|
||||
case '\n': *cptr++ = '\\'; *cptr++ = 'n'; b += 2; break;
|
||||
case '\r': *cptr++ = '\\'; *cptr++ = 'r'; b += 2; break;
|
||||
case '\t': *cptr++ = '\\'; *cptr++ = 't'; b += 2; break;
|
||||
case '\v': *cptr++ = '\\'; *cptr++ = 'v'; b += 2; break;
|
||||
case '\\': *cptr++ = '\\'; *cptr++ = '\\'; b += 2; break;
|
||||
case '"': *cptr++ = '\\'; *cptr++ = '"'; b += 2; break;
|
||||
default:
|
||||
if (*uc < 0x100 && isprint(*uc))
|
||||
{
|
||||
*cptr++ = *uc;
|
||||
b++;
|
||||
}
|
||||
else
|
||||
{
|
||||
int n = sprintf(cptr, "\\x%04x", *uc & 0xffff);
|
||||
cptr += n;
|
||||
b += n;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(i < len-1 && b >= 72)
|
||||
{
|
||||
*cptr++ = '"';
|
||||
*cptr++ = ',';
|
||||
*cptr++ = '\n';
|
||||
*cptr++ = ' ';
|
||||
*cptr++ = 'L';
|
||||
*cptr++ = '"';
|
||||
b = 0;
|
||||
}
|
||||
}
|
||||
if (unicodeout)
|
||||
len = (len + 1) & ~1;
|
||||
else
|
||||
len = (len + 3) & ~3;
|
||||
for(; i < len; i++)
|
||||
{
|
||||
*cptr++ = '\\';
|
||||
*cptr++ = 'x';
|
||||
*cptr++ = '0';
|
||||
*cptr++ = '0';
|
||||
*cptr++ = '0';
|
||||
*cptr++ = '0';
|
||||
}
|
||||
*cptr++ = '"';
|
||||
*cptr = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
char *tmp, *cc;
|
||||
int unilen = unistrlen(uc) + 1;
|
||||
|
||||
cc = tmp = xmalloc( unilen * 2 );
|
||||
wmc_wcstombs( codepage, 0, uc, unilen, cptr, unilen * 2 );
|
||||
*cptr++ = ' ';
|
||||
*cptr++ = '"';
|
||||
for(i = b = 0; i < len; i++, cc++)
|
||||
{
|
||||
switch(*cc)
|
||||
{
|
||||
case '\a': *cptr++ = '\\'; *cptr++ = 'a'; b += 2; break;
|
||||
case '\b': *cptr++ = '\\'; *cptr++ = 'b'; b += 2; break;
|
||||
case '\f': *cptr++ = '\\'; *cptr++ = 'f'; b += 2; break;
|
||||
case '\n': *cptr++ = '\\'; *cptr++ = 'n'; b += 2; break;
|
||||
case '\r': *cptr++ = '\\'; *cptr++ = 'r'; b += 2; break;
|
||||
case '\t': *cptr++ = '\\'; *cptr++ = 't'; b += 2; break;
|
||||
case '\v': *cptr++ = '\\'; *cptr++ = 'v'; b += 2; break;
|
||||
case '\\': *cptr++ = '\\'; *cptr++ = '\\'; b += 2; break;
|
||||
case '"': *cptr++ = '\\'; *cptr++ = '"'; b += 2; break;
|
||||
default:
|
||||
if(isprint(*cc))
|
||||
{
|
||||
*cptr++ = *cc;
|
||||
b++;
|
||||
}
|
||||
else
|
||||
{
|
||||
int n = sprintf(cptr, "\\x%02x", *cc & 0xff);
|
||||
cptr += n;
|
||||
b += n;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(i < len-1 && b >= 72)
|
||||
{
|
||||
*cptr++ = '"';
|
||||
*cptr++ = ',';
|
||||
*cptr++ = '\n';
|
||||
*cptr++ = ' ';
|
||||
*cptr++ = '"';
|
||||
b = 0;
|
||||
}
|
||||
}
|
||||
len = (len + 3) & ~3;
|
||||
for(; i < len; i++)
|
||||
{
|
||||
*cptr++ = '\\';
|
||||
*cptr++ = 'x';
|
||||
*cptr++ = '0';
|
||||
*cptr++ = '0';
|
||||
}
|
||||
*cptr++ = '"';
|
||||
*cptr = '\0';
|
||||
free(tmp);
|
||||
}
|
||||
return str;
|
||||
*cptr++ = ' ';
|
||||
*cptr++ = 'L';
|
||||
*cptr++ = '"';
|
||||
for(i = b = 0; i < len; i++, uc++)
|
||||
{
|
||||
switch(*uc)
|
||||
{
|
||||
case '\a': *cptr++ = '\\'; *cptr++ = 'a'; b += 2; break;
|
||||
case '\b': *cptr++ = '\\'; *cptr++ = 'b'; b += 2; break;
|
||||
case '\f': *cptr++ = '\\'; *cptr++ = 'f'; b += 2; break;
|
||||
case '\n': *cptr++ = '\\'; *cptr++ = 'n'; b += 2; break;
|
||||
case '\r': *cptr++ = '\\'; *cptr++ = 'r'; b += 2; break;
|
||||
case '\t': *cptr++ = '\\'; *cptr++ = 't'; b += 2; break;
|
||||
case '\v': *cptr++ = '\\'; *cptr++ = 'v'; b += 2; break;
|
||||
case '\\': *cptr++ = '\\'; *cptr++ = '\\'; b += 2; break;
|
||||
case '"': *cptr++ = '\\'; *cptr++ = '"'; b += 2; break;
|
||||
default:
|
||||
if (*uc < 0x100 && isprint(*uc))
|
||||
{
|
||||
*cptr++ = *uc;
|
||||
b++;
|
||||
}
|
||||
else
|
||||
{
|
||||
int n = sprintf(cptr, "\\x%04x", *uc);
|
||||
cptr += n;
|
||||
b += n;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(i < len-1 && b >= 72)
|
||||
{
|
||||
*cptr++ = '"';
|
||||
*cptr++ = ',';
|
||||
*cptr++ = '\n';
|
||||
*cptr++ = ' ';
|
||||
*cptr++ = 'L';
|
||||
*cptr++ = '"';
|
||||
b = 0;
|
||||
}
|
||||
}
|
||||
len = (len + 1) & ~1;
|
||||
for(; i < len; i++)
|
||||
{
|
||||
*cptr++ = '\\';
|
||||
*cptr++ = 'x';
|
||||
*cptr++ = '0';
|
||||
*cptr++ = '0';
|
||||
*cptr++ = '0';
|
||||
*cptr++ = '0';
|
||||
}
|
||||
*cptr++ = '"';
|
||||
*cptr = '\0';
|
||||
return str;
|
||||
}
|
||||
|
||||
static void write_rcinline(FILE *fp)
|
||||
|
@ -462,11 +398,9 @@ static void write_rcinline(FILE *fp)
|
|||
char *cptr;
|
||||
int l = blk->msgs[j]->len;
|
||||
const char *comma = j == blk->nmsg-1 && i == lbp->nblk-1 ? "" : ",";
|
||||
cptr = make_string(blk->msgs[j]->msg, l, unicodeout ? 0 : blk->msgs[j]->cp);
|
||||
fprintf(fp, "\n /* Msg 0x%08x */ 0x%04x, 0x000%c,\n",
|
||||
blk->idlo + j,
|
||||
(unicodeout ? (l*2+3)&~3 : (l+3)&~3) + 4,
|
||||
unicodeout ? '1' : '0');
|
||||
cptr = make_string(blk->msgs[j]->msg, l);
|
||||
fprintf(fp, "\n /* Msg 0x%08x */ 0x%04x, 0x0001,\n",
|
||||
blk->idlo + j, ((l * 2 + 3) & ~3) + 4 );
|
||||
fprintf(fp, "%s%s\n", cptr, comma);
|
||||
free(cptr);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue