To: vim_dev@googlegroups.com Subject: Patch 8.1.0059 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.0059 Problem: Displayed digraph for "ga" wrong with 'encoding' "cp1251". Solution: Convert from 'encoding' to "utf-8" if needed. (closes #3015) Files: src/digraph.c, src/testdir/test_digraph.vim *** ../vim-8.1.0058/src/digraph.c 2018-02-27 20:01:13.000000000 +0100 --- src/digraph.c 2018-06-16 17:06:04.657272887 +0200 *************** *** 1979,1992 **** * If not found return NULL. */ char_u * ! get_digraph_for_char(val) ! int val; { int i; int use_defaults; digr_T *dp; static char_u r[3]; for (use_defaults = 0; use_defaults <= 1; use_defaults++) { if (use_defaults == 0) --- 1979,2015 ---- * If not found return NULL. */ char_u * ! get_digraph_for_char(int val_arg) { + int val = val_arg; int i; int use_defaults; digr_T *dp; static char_u r[3]; + #if defined(FEAT_MBYTE) && defined(USE_UNICODE_DIGRAPHS) + if (!enc_utf8) + { + char_u buf[6], *to; + vimconv_T vc; + + // convert the character from 'encoding' to Unicode + i = mb_char2bytes(val, buf); + vc.vc_type = CONV_NONE; + if (convert_setup(&vc, p_enc, (char_u *)"utf-8") == OK) + { + vc.vc_fail = TRUE; + to = string_convert(&vc, buf, &i); + if (to != NULL) + { + val = utf_ptr2char(to); + vim_free(to); + } + (void)convert_setup(&vc, NULL, NULL); + } + } + #endif + for (use_defaults = 0; use_defaults <= 1; use_defaults++) { if (use_defaults == 0) *** ../vim-8.1.0058/src/testdir/test_digraph.vim 2018-02-27 21:08:09.000000000 +0100 --- src/testdir/test_digraph.vim 2018-06-16 17:15:21.629331405 +0200 *************** *** 465,468 **** --- 465,480 ---- bwipe! endfunc + func Test_show_digraph_cp1251() + if !has('multi_byte') + return + endif + new + set encoding=cp1251 + call Put_Dig("='") + call assert_equal("\n<\xfa> <|z> 250, Hex fa, Oct 372, Digr ='", execute('ascii')) + set encoding=utf-8 + bwipe! + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.1.0058/src/version.c 2018-06-16 16:20:48.772597946 +0200 --- src/version.c 2018-06-16 17:07:11.244898262 +0200 *************** *** 763,764 **** --- 763,766 ---- { /* Add new patch number below this line */ + /**/ + 59, /**/ -- hundred-and-one symptoms of being an internet addict: 53. To find out what time it is, you send yourself an e-mail and check the "Date:" field. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///