On 21/09/09 03:48, Tim Chase wrote:
>
>> gvim
>> encoding=latin1
>> guifont=
>
> I suspect the "latin1" is the bulk of the problem, and if your
> default font doesn't support a full compliment of characters,
> that would compound the issue.  Try setting your encoding to
> "utf-8" and then possibly re-pasting.  This is where Tony usually
> jumps in with his much deeper expertise on all the peculiarities
> of unicode/encodings/fonts/etc.  At least from my testing (on
> Debian), I did the following:
>
>    1) start gvim
>    2) :set encoding=utf-8
>    3) pasted the content of your original message with non-latin1
> characters
>
> and it displayed as desired.
>
> -tim

Sorry for being late, this tells you how far behind I am in reading 
Vim-list mail.

'encoding' (global) is what Vim uses to represent your files in memory, 
so anything that has no representation in that charset can simply not be 
represented in the current Vim session.

'fileencoding' (singular) (buffer-local) is the charset used on disk for 
one particular file.

'fileencodings' (plural) (global) is what Vim uses when guessing the 
charset of a file you open for editing if you don't say what it is

++enc=<something> (see ":help ++opt") is how you tell Vim which charset 
to use for a file.

All this, and more, is explained in detail in the help; the bulk of the 
matter is in the mbyte.txt helpfile, and the most important points, with 
links to various places in the help for further reading, are at 
http://vim.wikia.org/wiki/Working_with_Unicode

I recommend to set 'encoding' to utf-8 when starting Vim, because that 
way, _any_ charset can be represented in memory, and, if the iconv 
utility is available, editfile data in memory can also be converted to 
and from any charset which can represent the desired data. Conversion 
between UTF-8 and Latin1 is trivial, Vim can do it without external help 
(simply put, Unicode codepoints U+0000 to U+00FF correspond in the same 
order with the characters 0x00 to 0xFF of Latin1; any other codepoint 
has no exact representation in Latin1).

Here is the part of my _current_ vimrc (near the start) charged with 
making sure that editing happens in UTF-8 whenever it is sourced by a 
Vim version equipped with that functionality, and that the transition is 
made "smoothly", e.g. without loss of keyboard functionality, and with 
correct representation of mappings and/or options containing upper-half 
Latin1 characters later on in the vimrc:

----8<----8<----8<----
" use 'nocompatible' mode even if sourced with -u
set nocompatible

" this script is in Latin1 even when 'encoding' is UTF-8
scriptencoding latin1

" some lines omitted here, concerned with other things
" which will be done before switching 'encoding'

" switch to UTF-8 if possible (and not already done by the OS)
" of course, if Vim has no multi_byte functionality, we cannot switch
" to a Unicode encoding: so on feature-poor Vims we bypass it all.
if has("multi_byte")
        " save the OS locale for reference and debugging
        let g:locale_encoding = &encoding
        if &encoding !~? '^u'           " ... if not already Unicode ...
                if &termencoding == ""
                        " 'termencoding' empty means: use 'encoding'
                        " but we're going to change the latter
                        " here we make sure understanding remains
                        " between Vim and keyboard and/or display
                        let &termencoding = &encoding
                endif
                " OK, now we're ready to switch
                set encoding=utf-8
        endif
        " the following must be done even if the system locale is UTF-8
        " auto-detect any Unicode file with BOM (ucs-bom must be first)
        " auto-detect UTF-8 files with or without BOM
        " fall back on Latin1 (must be last) if autodetection fails
        " Note: only one 8-bit charset can be used, and it must be last
        set fileencodings=ucs-bom,utf-8,latin1
        " define defaults for new files: we use UTF-8 with BOM
        " if 'bomb' is set for non-Unicode files, it has no effect
        " however, ":setg bomb fenc=latin1" is not silly, it would just
        " mean that new files default to Latin1, and that Unicode files
        " default to BOM present.
        setg bomb fileencoding=utf-8
        " the following is commented-out; I haven't succeeded (yet?) to
        " make it work properly
"       if has("printer")
"               set penc=utf-8
"       endif
endif

" custom status line, see :help 'statusline' for details
" it is similar but not identical with the default
" among other niceties, it includes near the right end:
"       - the current keymap (if active),
"       - the disk charset and (if used) BOM setting of the current file
"       - the Unicode codepoint under the cursor in hex
if has("statusline")
        " below is one long line
        set statusline=%<%f\ %h%m%r%=%k[%{(&fenc\ ==\ 
\"\"?&enc:&fenc).(&bomb?\",BOM\":\"\")}][U+%04B]\ %-12.(%l,%c%V%)\ %P
        " the above is one long line
endif
---->8---->8---->8----



Best regards,
Tony.
-- 
hundred-and-one symptoms of being an internet addict:
156. You forget your friend's name but not her e-mail address.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to