aboutsummaryrefslogtreecommitdiff
path: root/binutils/winduni.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2007-06-18 15:30:33 +0000
committerNick Clifton <nickc@redhat.com>2007-06-18 15:30:33 +0000
commitd856f2ddfa3d037987610ecc0edbf75f31296971 (patch)
treec7758a45b5d8f12f2bd4ea57e4a1588263c89789 /binutils/winduni.c
parent5d41b3efe4d718fac501a7ee7afd96dbd62ded6e (diff)
downloadgdb-d856f2ddfa3d037987610ecc0edbf75f31296971.zip
gdb-d856f2ddfa3d037987610ecc0edbf75f31296971.tar.gz
gdb-d856f2ddfa3d037987610ecc0edbf75f31296971.tar.bz2
* rclex.c: (cpp_line): Add code_page pragma support.
* windres.c: (usage, long_options, main): Add new option --codepage or -c. * winduni.c: (wind_default_codepage, wind_current_codepage): New. (unicode_from_ascii, ascii_from_unicode): Use wind_current_codepage as codepage parameter. (unicode_print): Print 4 characters for hexadecimal values in unicode strings. * winduni.h: (wind_default_codepage, wind_current_codepage): Export. * doc/binutils.texi: Document new option. * NEWS: Mention new feature.
Diffstat (limited to 'binutils/winduni.c')
-rw-r--r--binutils/winduni.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/binutils/winduni.c b/binutils/winduni.c
index c4f4b1b..f1bd58a 100644
--- a/binutils/winduni.c
+++ b/binutils/winduni.c
@@ -47,10 +47,11 @@
static rc_uint_type wind_WideCharToMultiByte (rc_uint_type, const unichar *, char *, rc_uint_type);
static rc_uint_type wind_MultiByteToWideChar (rc_uint_type, const char *, unichar *, rc_uint_type);
-
-/* Prototypes. */
static int unichar_isascii (const unichar *, rc_uint_type);
+/* Convert an ASCII string to a unicode string. We just copy it,
+ expanding chars to shorts, rather than doing something intelligent. */
+
#if !defined (_WIN32) && !defined (__CYGWIN__)
/* Codepages mapped. */
@@ -175,13 +176,21 @@ static const wind_language_t languages[] =
#endif
+/* Specifies the default codepage to be used for unicode
+ transformations. By default this is CP_ACP. */
+rc_uint_type wind_default_codepage = CP_ACP;
+
+/* Specifies the currently used codepage for unicode
+ transformations. By default this is CP_ACP. */
+rc_uint_type wind_current_codepage = CP_ACP;
+
/* Convert an ASCII string to a unicode string. We just copy it,
expanding chars to shorts, rather than doing something intelligent. */
void
unicode_from_ascii (rc_uint_type *length, unichar **unicode, const char *ascii)
{
- unicode_from_codepage (length, unicode, ascii, 0 /*CP_ACP*/);
+ unicode_from_codepage (length, unicode, ascii, wind_current_codepage);
}
/* Convert an unicode string to an ASCII string. We just copy it,
@@ -191,7 +200,7 @@ unicode_from_ascii (rc_uint_type *length, unichar **unicode, const char *ascii)
void
ascii_from_unicode (rc_uint_type *length, const unichar *unicode, char **ascii)
{
- codepage_from_unicode (length, unicode, ascii, 0/*CP_ACP*/);
+ codepage_from_unicode (length, unicode, ascii, wind_current_codepage);
}
/* Print the unicode string UNICODE to the file E. LENGTH is the
@@ -267,7 +276,7 @@ unicode_print (FILE *e, const unichar *unicode, rc_uint_type length)
else if ((ch & 0xff) == ch)
fprintf (e, "\\%03o", (unsigned int) ch);
else
- fprintf (e, "\\x%x", (unsigned int) ch);
+ fprintf (e, "\\x%04x", (unsigned int) ch);
}
}