diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-06-16 17:25:22 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-06-16 17:25:22 +0200 |
commit | bc5020aa4d7ef4aea88395eff858f74fc881eab9 (patch) | |
tree | 86abc96e4efcfa1667ba9c33e7fe1b48a2251845 /src | |
parent | bfa4246768e28335ed9b98f83019ea58b480158e (diff) | |
download | vim-git-bc5020aa4d7ef4aea88395eff858f74fc881eab9.tar.gz |
patch 8.1.0059: displayed digraph for "ga" wrong with 'encoding' "cp1251"v8.1.0059
Problem: Displayed digraph for "ga" wrong with 'encoding' "cp1251".
Solution: Convert from 'encoding' to "utf-8" if needed. (closes #3015)
Diffstat (limited to 'src')
-rw-r--r-- | src/digraph.c | 27 | ||||
-rw-r--r-- | src/testdir/test_digraph.vim | 12 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 39 insertions, 2 deletions
diff --git a/src/digraph.c b/src/digraph.c index 6f9c46ff7..6909c5b9c 100644 --- a/src/digraph.c +++ b/src/digraph.c @@ -1979,14 +1979,37 @@ do_digraph(int c) * If not found return NULL. */ char_u * -get_digraph_for_char(val) - int val; +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) diff --git a/src/testdir/test_digraph.vim b/src/testdir/test_digraph.vim index 271066df4..d5b0a7b72 100644 --- a/src/testdir/test_digraph.vim +++ b/src/testdir/test_digraph.vim @@ -465,4 +465,16 @@ func Test_show_digraph() 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> <M-z> 250, Hex fa, Oct 372, Digr ='", execute('ascii')) + set encoding=utf-8 + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index f7c5f2efa..68b4c26b8 100644 --- a/src/version.c +++ b/src/version.c @@ -762,6 +762,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 59, +/**/ 58, /**/ 57, |