From: Jason Rumney Date: Tue, 5 Feb 2008 23:48:23 +0000 (+0000) Subject: (w32_read_socket) : Use locale-coding-system X-Git-Tag: emacs-pretest-22.1.91~60 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=85bb72eefdd7bfc5da9e19fd42c92e6fc748fed4;p=emacs.git (w32_read_socket) : Use locale-coding-system instead of using mule-unicode-* charsets directly. --- diff --git a/src/ChangeLog b/src/ChangeLog index 0288554acd0..f7d6c07a086 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2008-02-05 Jason Rumney + + * w32term.c (w32_read_socket) : Use locale-coding-system + instead of using mule-unicode-* charsets directly. + 2008-02-05 Juanma Barranquero * unexec.c (make_hdr): diff --git a/src/w32term.c b/src/w32term.c index 23b79008402..2b007b14b44 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -4338,7 +4338,7 @@ w32_read_socket (sd, expected, hold_quit) } } - /* Now process unicode input as per xterm.c */ + /* Process unicode input for ASCII and ISO Control only. */ if (code < 0x80) { inev.kind = ASCII_KEYSTROKE_EVENT; @@ -4346,82 +4346,56 @@ w32_read_socket (sd, expected, hold_quit) } else if (code < 0xA0) inev.code = MAKE_CHAR (CHARSET_8_BIT_CONTROL, code, 0); - else if (code < 0x100) - inev.code = MAKE_CHAR (charset_latin_iso8859_1, code, 0); else { - int c1, c2; - int charset_id; - - if (code < 0x2500) - { - charset_id = charset_mule_unicode_0100_24ff; - code -= 0x100; - } - else if (code < 0x3400) + /* Many locales do not have full mapping from + unicode on save, so use the locale coding to + decode them. Windows only allows non-Unicode + Windows to receive characters in the system + locale anyway, so this doesn't really limit + us. */ + int nbytes, nchars, require, i, len; + unsigned char *dest; + struct coding_system coding; + + if (dbcs[0] == 0) { - charset_id = charset_mule_unicode_2500_33ff; - code -= 0x2500; - } - else if (code >= 0xE000) - { - charset_id = charset_mule_unicode_e000_ffff; - code -= 0xE000; + nbytes = 1; + dbcs[0] = dbcs[1]; } else - { - /* Not in the unicode range that we can handle in - Emacs-22, so decode the original character - using the locale */ - int nbytes, nchars, require, i, len; - unsigned char *dest; - struct coding_system coding; - - if (dbcs[0] == 0) - { - nbytes = 1; - dbcs[0] = dbcs[1]; - } - else - nbytes = 2; + nbytes = 2; - setup_coding_system (Vlocale_coding_system, &coding); - coding.src_multibyte = 0; - coding.dst_multibyte = 1; - coding.composing = COMPOSITION_DISABLED; - require = decoding_buffer_size (&coding, nbytes); - dest = (unsigned char *) alloca (require); - coding.mode |= CODING_MODE_LAST_BLOCK; + setup_coding_system (Vlocale_coding_system, &coding); + coding.src_multibyte = 0; + coding.dst_multibyte = 1; + coding.composing = COMPOSITION_DISABLED; + require = decoding_buffer_size (&coding, nbytes); + dest = (unsigned char *) alloca (require); + coding.mode |= CODING_MODE_LAST_BLOCK; - decode_coding (&coding, dbcs, dest, nbytes, require); - nbytes = coding.produced; - nchars = coding.produced_char; + decode_coding (&coding, dbcs, dest, nbytes, require); + nbytes = coding.produced; + nchars = coding.produced_char; - for (i = 0; i < nbytes; i += len) + for (i = 0; i < nbytes; i += len) + { + if (nchars == nbytes) { - if (nchars == nbytes) - { - inev.code = dest[i]; - len = 1; - } - else - inev.code = STRING_CHAR_AND_LENGTH (dest + i, - nbytes - 1, - len); - inev.kind = (SINGLE_BYTE_CHAR_P (inev.code) - ? ASCII_KEYSTROKE_EVENT - : MULTIBYTE_CHAR_KEYSTROKE_EVENT); - kbd_buffer_store_event_hold (&inev, hold_quit); - count++; + inev.code = dest[i]; + len = 1; } - inev.kind = NO_EVENT; /* Already handled */ - break; + else + inev.code = STRING_CHAR_AND_LENGTH (dest + i, + nbytes - 1, + len); + inev.kind = (SINGLE_BYTE_CHAR_P (inev.code) + ? ASCII_KEYSTROKE_EVENT + : MULTIBYTE_CHAR_KEYSTROKE_EVENT); + kbd_buffer_store_event_hold (&inev, hold_quit); + count++; } - - /* Unicode characters from above. */ - c1 = (code / 96) + 32; - c2 = (code % 96) + 32; - inev.code = MAKE_CHAR (charset_id, c1, c2); + inev.kind = NO_EVENT; /* Already handled */ } } else @@ -4430,7 +4404,6 @@ w32_read_socket (sd, expected, hold_quit) in non-Unicode message handlers. */ DebPrint (("Non-byte WM_CHAR: %d\n", msg.msg.wParam)); inev.kind = NO_EVENT; - break; } } break;