Add one thing. It's better to check encoding isn't latin1 like.
https://gist.github.com/1400283 > I wonder how many users still use another encoding than utf-8. > Unicode makes life so much simpler. A lot of windows users probably uses DBCS encodings. For example, the order of character codes are not same between cp932 and utf-8. We must change the way of regular expression. like [ア-ンあ-ん] to match with japanese hiragana. And also, I'm thinking that some application doesn't work correctly with utf-8 encoding even if it's on unix. ex: ambigous widths, lack of fixed with fonts, and dictionaries, etc. diff -r 379a6398d462 src/quickfix.c --- a/src/quickfix.c Wed Oct 26 23:48:21 2011 +0200 +++ b/src/quickfix.c Tue Nov 29 09:00:19 2011 +0900 @@ -3914,6 +3914,14 @@ regmatch.rm_ic = FALSE; if (regmatch.regprog != NULL) { +#ifdef FEAT_MBYTE + vimconv_T vc; + + vc.vc_type = CONV_NONE; + if (!enc_utf8 && !enc_latin1like) + convert_setup(&vc, "utf-8", p_enc); +#endif + /* create a new quickfix list */ qf_new_list(qi, *eap->cmdlinep); @@ -3948,21 +3956,31 @@ lnum = 1; while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int) { - if (vim_regexec(®match, IObuff, (colnr_T)0)) + + char_u *line = IObuff; +#ifdef FEAT_MBYTE + if (vc.vc_type != CONV_NONE) { + line = string_convert(&vc, IObuff, NULL); + if (!line) + line = IObuff; + } +#endif + + if (vim_regexec(®match, line, (colnr_T)0)) { - int l = (int)STRLEN(IObuff); + int l = (int)STRLEN(line); /* remove trailing CR, LF, spaces, etc. */ - while (l > 0 && IObuff[l - 1] <= ' ') - IObuff[--l] = NUL; + while (l > 0 && line[l - 1] <= ' ') + line[--l] = NUL; if (qf_add_entry(qi, &prevp, NULL, /* dir */ fnames[fi], 0, - IObuff, + line, lnum, - (int)(regmatch.startp[0] - IObuff) + (int)(regmatch.startp[0] - line) + 1, /* col */ FALSE, /* vis_col */ NULL, /* search pattern */ @@ -3975,6 +3993,11 @@ break; } } +#ifdef FEAT_MBYTE + if (line != IObuff) + vim_free(line); +#endif + ++lnum; line_breakcheck(); } @@ -3990,6 +4013,11 @@ qi->qf_lists[qi->qf_curlist].qf_ptr = qi->qf_lists[qi->qf_curlist].qf_start; qi->qf_lists[qi->qf_curlist].qf_index = 1; + +#ifdef FEAT_MBYTE + if (vc.vc_type != CONV_NONE) + convert_setup(&vc, NULL, NULL); +#endif } if (p_cpo == empty_option) -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
