4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
11 Problem: Non-latin1 help files are not properly supported.
12 Solution: Support utf-8 help files and convert them to 'encoding' when
17 *** ../vim-6.2.497/src/fileio.c Tue Apr 20 12:52:53 2004
18 --- src/fileio.c Sun Apr 25 14:21:50 2004
24 int conv_error = FALSE; /* conversion error detected */
25 + int keep_dest_enc = FALSE; /* don't retry when char doesn't fit
26 + in destination encoding */
27 linenr_T illegal_byte = 0; /* line nr with illegal byte */
28 char_u *tmpname = NULL; /* name of 'charconvert' output file */
33 else if (curbuf->b_help)
35 /* Help files are either utf-8 or latin1. Try utf-8 first, if this
36 ! * fails it must be latin1. Only do this when 'encoding' is utf-8 to
37 ! * avoid [converted] remarks all the time. */
38 fenc = (char_u *)"latin1";
42 fenc = (char_u *)"utf-8";
48 else if (curbuf->b_help)
50 + char_u firstline[80];
52 /* Help files are either utf-8 or latin1. Try utf-8 first, if this
53 ! * fails it must be latin1.
54 ! * Always do this when 'encoding' is "utf-8". Otherwise only do
55 ! * this when needed to avoid [converted] remarks all the time.
56 ! * It is needed when the first line contains non-ASCII characters.
57 ! * That is only in *.??x files. */
58 fenc = (char_u *)"latin1";
60 ! if (!c && !read_stdin && TOLOWER_ASC(fname[STRLEN(fname) - 1]) == 'x')
62 ! /* Read the first line (and a bit more). Immediately rewind to
63 ! * the start of the file. If the read() fails "len" is -1. */
64 ! len = vim_read(fd, firstline, 80);
65 ! lseek(fd, (off_t)0L, SEEK_SET);
66 ! for (p = firstline; p < firstline + len; ++p)
77 fenc = (char_u *)"utf-8";
79 + /* When the file is utf-8 but a character doesn't fit in
80 + * 'encoding' don't retry. In help text editing utf-8 bytes
81 + * doesn't make sense. */
82 + keep_dest_enc = TRUE;
88 /* character doesn't fit in latin1, retry with
89 * another fenc when possible, otherwise just
90 * report the error. */
96 /* character doesn't fit in latin1, retry with
97 * another fenc when possible, otherwise just
98 * report the error. */
99 ! if (can_retry && !keep_dest_enc)
103 *** ../vim-6.2.497/src/version.c Sun Apr 25 14:42:43 2004
104 --- src/version.c Sun Apr 25 14:44:21 2004
108 { /* Add new patch number below this line */
115 -- The Hitchhiker's Guide to the Galaxy
117 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
118 /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
119 \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
120 \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///